Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a7de2fe
Pass policy prop to MoneyRequestReportTransactionItem and include in …
mukhrr Mar 3, 2026
b15f393
Add sorting support for additional transaction columns
mukhrr Mar 3, 2026
fd89390
Add COMMENTS column to transaction search results when not already pr…
mukhrr Mar 3, 2026
6f0e9a6
Move transaction sorting logic to ReportUtils and add policy paramete…
mukhrr Mar 3, 2026
e1b4012
Remove sortableColumns prop and use isSortableColumnName directly in …
mukhrr Mar 3, 2026
f04a483
added missing tests
mukhrr Mar 3, 2026
c96dc99
Update test expectations to match tax rate display format and clarify…
mukhrr Mar 3, 2026
4f7eb96
Add tests for TOTAL_AMOUNT, DESCRIPTION, EXCHANGE_RATE, ORIGINAL_AMOU…
mukhrr Mar 3, 2026
baec04a
Add sorting support for CARD column in transaction search results
mukhrr Mar 4, 2026
5ee3cf7
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 4, 2026
a6cf6d1
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 4, 2026
71a0474
Add fallback exchange rate calculation using convertedAmount when gro…
mukhrr Mar 4, 2026
b0920c2
Pass isCardFeedDeleted prop through transaction components and update…
mukhrr Mar 5, 2026
4b3e163
Add dynamic column filtering for custom report views to hide empty co…
mukhrr Mar 5, 2026
0f9fac2
Add comprehensive unit tests for exchange rate and empty column filte…
mukhrr Mar 5, 2026
cb62d04
Add deletedCard translation key across all supported languages
mukhrr Mar 5, 2026
75ae906
Replace hardcoded 0 with CONST.DEFAULT_NUMBER_ID for card sorting fal…
mukhrr Mar 5, 2026
d8f538b
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 5, 2026
2327c67
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 6, 2026
ff2415e
Fix exchange rate calculation and column visibility in expense report…
mukhrr Mar 6, 2026
49c696b
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 6, 2026
8a2eeaf
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 15, 2026
fc5ee7f
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 17, 2026
2465a14
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 19, 2026
5a2645d
Refactor getColumnsToShow to use named parameters object instead of p…
mukhrr Mar 19, 2026
a977f5e
Add currencyConversionRate field to transaction types and use it for …
mukhrr Mar 19, 2026
0fd78f7
Simplify exchange rate calculation by removing unnecessary Number con…
mukhrr Mar 19, 2026
d8a2b3f
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 19, 2026
6efbdaa
Fix card feed deletion check and column visibility logic
mukhrr Mar 19, 2026
0e6350d
Fix custom report columns visibility logic to detect empty columns
mukhrr Mar 20, 2026
29df04c
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 20, 2026
7cae133
Alphabetize getTransactionSortValue import in ReportUtilsTest
mukhrr Mar 20, 2026
cc1c2a3
Refine custom report column visibility logic to prevent showing empty…
mukhrr Mar 21, 2026
243969e
Remove redundant type assertions in total sorting logic
mukhrr Mar 21, 2026
683a319
Add logic to conditionally show SUBMITTED, POLICY_NAME, and TO column…
mukhrr Mar 21, 2026
ca0171b
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 24, 2026
73dcc84
Pass customCardNames to MoneyRequestReportTransactionItem and resolve…
mukhrr Mar 24, 2026
56addf2
Refactor card field resolution into CardUtils and apply to transactio…
mukhrr Mar 24, 2026
18abf26
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 24, 2026
4c940c5
Merge remote-tracking branch 'origin' into fix/custom-report-columns
mukhrr Mar 26, 2026
53df622
Update `getColumnsToShow` call to use named parameters in SortByPopup
mukhrr Mar 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {getExpenseHeaders} from '@components/Search/SearchTableHeader';
import SortableTableHeader from '@components/Search/SortableTableHeader';
import type {SearchColumnType, SortOrder, TableColumnSize} from '@components/Search/types';
import useThemeStyles from '@hooks/useThemeStyles';
import {isSortableColumnName} from '@libs/ReportUtils';
import CONST from '@src/CONST';

type SearchTableHeaderProps = {
Expand All @@ -15,34 +16,23 @@ type SearchTableHeaderProps = {
taxAmountColumnSize: TableColumnSize;
shouldShowSorting: boolean;
columns: SearchColumnType[];
sortableColumns?: readonly SearchColumnType[];
};
function MoneyRequestReportTableHeader({
sortBy,
sortOrder,
onSortPress,
dateColumnSize,
shouldShowSorting,
columns,
amountColumnSize,
taxAmountColumnSize,
sortableColumns,
}: SearchTableHeaderProps) {
function MoneyRequestReportTableHeader({sortBy, sortOrder, onSortPress, dateColumnSize, shouldShowSorting, columns, amountColumnSize, taxAmountColumnSize}: SearchTableHeaderProps) {
const styles = useThemeStyles();

const columnConfig = useMemo(
() => [
...getExpenseHeaders().map((header) => ({
...header,
isColumnSortable: sortableColumns ? sortableColumns.includes(header.columnName) : header.isColumnSortable,
isColumnSortable: isSortableColumnName(header.columnName),
})),
{
columnName: CONST.SEARCH.TABLE_COLUMNS.COMMENTS,
translationKey: undefined,
isColumnSortable: false,
},
],
[sortableColumns],
[],
);

const orderedColumnConfig = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type MoneyRequestReportTransactionItemProps = {

/** Whether this transaction should be highlighted as newly added */
shouldBeHighlighted: boolean;

/** Custom card names mapping cardID to display name */
customCardNames?: Record<number, string>;
};

function MoneyRequestReportTransactionItem({
Expand All @@ -84,6 +87,7 @@ function MoneyRequestReportTransactionItem({
scrollToNewTransaction,
onArrowRightPress,
shouldBeHighlighted,
customCardNames,
}: MoneyRequestReportTransactionItemProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
Expand Down Expand Up @@ -161,6 +165,7 @@ function MoneyRequestReportTransactionItem({
}}
onArrowRightPress={() => onArrowRightPress?.(transaction.transactionID)}
isHover={hovered}
customCardNames={customCardNames}
/>
)}
</PressableWithFeedback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {View} from 'react-native';
// ScrollView type is needed for the horizontal scroll ref; the project ScrollView component is used for rendering.
// eslint-disable-next-line no-restricted-imports
import type {LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent, ScrollView as RNScrollView} from 'react-native';
import type {TupleToUnion} from 'type-fest';
import Button from '@components/Button';
import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu';
import Checkbox from '@components/Checkbox';
import MenuItem from '@components/MenuItem';
Expand All @@ -15,7 +15,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import ScrollView from '@components/ScrollView';
import DropdownButton from '@components/Search/FilterDropdowns/DropdownButton';
import {useSearchActionsContext, useSearchStateContext} from '@components/Search/SearchContext';
import type {SearchColumnType, SearchCustomColumnIds, SortOrder} from '@components/Search/types';
import type {SearchCustomColumnIds, SortOrder} from '@components/Search/types';
import SelectionList from '@components/SelectionList';
import SingleSelectListItem from '@components/SelectionList/ListItem/SingleSelectListItem';
import Text from '@components/Text';
Expand All @@ -31,16 +31,17 @@ import useReportIsArchived from '@hooks/useReportIsArchived';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useResponsiveLayoutOnWideRHP from '@hooks/useResponsiveLayoutOnWideRHP';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import {turnOnMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import {setOptimisticTransactionThread} from '@libs/actions/Report';
import {getReportLayoutGroupBy, setReportLayoutGroupBy} from '@libs/actions/ReportLayout';
import {clearActiveTransactionIDs, setActiveTransactionIDs} from '@libs/actions/TransactionThreadNavigation';
import {resolveTransactionCardFields} from '@libs/CardUtils';
import {convertToDisplayString} from '@libs/CurrencyUtils';
import {hasNonReimbursableTransactions, isBillableEnabledOnPolicy} from '@libs/MoneyRequestReportUtils';
import {navigationRef} from '@libs/Navigation/Navigation';
import Parser from '@libs/Parser';
import {isPolicyTaxEnabled} from '@libs/PolicyUtils';
import {getIOUActionForTransactionID} from '@libs/ReportActionsUtils';
import {groupTransactionsByCategory, groupTransactionsByTag} from '@libs/ReportLayoutUtils';
Expand All @@ -50,12 +51,15 @@ import {
getBillableAndTaxTotal,
getMoneyRequestSpendBreakdown,
getReportOfflinePendingActionAndErrors,
getTransactionSortValue,
isCurrentUserSubmitter,
isExpenseReport,
isIOUReport,
isSortableColumnName,
} from '@libs/ReportUtils';
import type {SortableColumnName} from '@libs/ReportUtils';
import {compareValues, getColumnsToShow, getTableMinWidth, isTransactionAmountTooLong, isTransactionTaxAmountTooLong} from '@libs/SearchUIUtils';
import {getAmount, getCategory, getCreated, getMerchant, getTag, getTransactionPendingAction, isTransactionPendingDelete, shouldShowExpenseBreakdown} from '@libs/TransactionUtils';
import {getTransactionPendingAction, isTransactionPendingDelete, shouldShowExpenseBreakdown} from '@libs/TransactionUtils';
import shouldShowTransactionYear from '@libs/TransactionUtils/shouldShowTransactionYear';
import Navigation from '@navigation/Navigation';
import type {ReportsSplitNavigatorParamList} from '@navigation/types';
Expand Down Expand Up @@ -110,47 +114,18 @@ type MoneyRequestReportTransactionListProps = {
type TransactionWithOptionalHighlight = OnyxTypes.Transaction & {
/** Whether the transaction should be highlighted, when it is added to the report */
shouldBeHighlighted?: boolean;
};

const sortableColumnNames = [
CONST.SEARCH.TABLE_COLUMNS.DATE,
CONST.SEARCH.TABLE_COLUMNS.MERCHANT,
CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION,
CONST.SEARCH.TABLE_COLUMNS.CATEGORY,
CONST.SEARCH.TABLE_COLUMNS.TAG,
CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT,
] as const satisfies readonly SearchColumnType[];
/** Whether the card feed has been deleted */
isCardFeedDeleted?: boolean;
};

type ReportScreenNavigationProps = ReportsSplitNavigatorParamList[typeof SCREENS.REPORT];

type SortableColumnName = TupleToUnion<typeof sortableColumnNames>;

type SortedTransactions = {
sortBy: SortableColumnName;
sortOrder: SortOrder;
};

const isSortableColumnName = (key: unknown): key is SortableColumnName => !!sortableColumnNames.find((val) => val === key);

const getTransactionValue = (transaction: OnyxTypes.Transaction, key: SortableColumnName, reportToSort: OnyxTypes.Report) => {
switch (key) {
case CONST.SEARCH.TABLE_COLUMNS.DATE:
return getCreated(transaction);
case CONST.SEARCH.TABLE_COLUMNS.MERCHANT:
return getMerchant(transaction);
case CONST.SEARCH.TABLE_COLUMNS.CATEGORY:
return getCategory(transaction);
case CONST.SEARCH.TABLE_COLUMNS.TAG:
return getTag(transaction);
case CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT:
return getAmount(transaction, isExpenseReport(reportToSort), transaction.reportID === CONST.REPORT.UNREPORTED_REPORT_ID);
case CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION:
return Parser.htmlToText(transaction.comment?.comment ?? '');
default:
return transaction[key];
}
};

function MoneyRequestReportTransactionList({
report,
transactions,
Expand All @@ -165,6 +140,7 @@ function MoneyRequestReportTransactionList({
}: MoneyRequestReportTransactionListProps) {
useCopySelectionHelper();
const styles = useThemeStyles();
const theme = useTheme();
const StyleUtils = useStyleUtils();
const expensifyIcons = useMemoizedLazyExpensifyIcons(['Location', 'CheckSquare', 'ReceiptPlus', 'Columns']);
const {translate, localeCompare} = useLocalize();
Expand Down Expand Up @@ -196,6 +172,9 @@ function MoneyRequestReportTransactionList({
const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
const [reportDetailsColumns] = useOnyx(ONYXKEYS.NVP_REPORT_DETAILS_COLUMNS);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [cardFeeds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER);
const [customCardNames] = useOnyx(ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES);
const [cardList] = useOnyx(ONYXKEYS.CARD_LIST);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});

const shouldShowGroupedTransactions = isExpenseReport(report) && !isIOUReport(report);
Expand Down Expand Up @@ -267,27 +246,30 @@ function MoneyRequestReportTransactionList({
const {sortBy, sortOrder} = sortConfig;

const sortedTransactions: TransactionWithOptionalHighlight[] = useMemo(() => {
return [...transactions].sort((a, b) => compareValues(getTransactionValue(a, sortBy, report), getTransactionValue(b, sortBy, report), sortOrder, sortBy, localeCompare, true));
}, [sortBy, sortOrder, transactions, localeCompare, report]);
return [...transactions].sort((a, b) =>
compareValues(getTransactionSortValue(a, sortBy, report, policy), getTransactionSortValue(b, sortBy, report, policy), sortOrder, sortBy, localeCompare, true),
);
}, [sortBy, sortOrder, transactions, localeCompare, report, policy]);

const resolvedTransactions = useMemo(() => resolveTransactionCardFields(sortedTransactions, cardList, cardFeeds, translate), [sortedTransactions, cardList, cardFeeds, translate]);

const highlightedTransactionIDs = useMemo(() => new Set(newTransactions.map(({transactionID}) => transactionID)), [newTransactions]);

// Always use default columns for money request report view (don't use user-customized search columns)
const isExpenseReportViewFromIOUReport = isIOUReport(report);
const shouldShowBillableColumn = isBillableEnabledOnPolicy(policy);
const columnsToShow = useMemo(() => {
return getColumnsToShow(
currentUserDetails?.accountID,
transactions,
(reportDetailsColumns ?? []) as SearchCustomColumnIds[],
true,
undefined,
undefined,
return getColumnsToShow({
currentAccountID: currentUserDetails?.accountID,
data: transactions,
visibleColumns: (isExpenseReportViewFromIOUReport ? [] : (reportDetailsColumns ?? [])) as SearchCustomColumnIds[],
isExpenseReportView: true,
isExpenseReportViewFromIOUReport,
shouldShowBillableColumn,
hasNonReimbursableTransactions(transactions),
);
}, [transactions, currentUserDetails?.accountID, isExpenseReportViewFromIOUReport, shouldShowBillableColumn, reportDetailsColumns]);
shouldShowReimbursableColumn: hasNonReimbursableTransactions(transactions),
reportCurrency: report?.currency,
});
}, [transactions, currentUserDetails?.accountID, isExpenseReportViewFromIOUReport, shouldShowBillableColumn, reportDetailsColumns, report?.currency]);

const {windowWidth, windowHeight} = useWindowDimensions();
const minTableWidth = getTableMinWidth(columnsToShow);
Expand All @@ -314,13 +296,13 @@ function MoneyRequestReportTransactionList({
return [];
}
if (currentGroupBy === CONST.REPORT_LAYOUT.GROUP_BY.TAG) {
return groupTransactionsByTag(sortedTransactions, report, localeCompare);
return groupTransactionsByTag(resolvedTransactions, report, localeCompare);
}
return groupTransactionsByCategory(sortedTransactions, report, localeCompare);
return groupTransactionsByCategory(resolvedTransactions, report, localeCompare);
// groupTransactionsByTag() and groupTransactionsByCategory() use the full report object to perform a null check.
// We skip including the report as a dependency to avoid unnecessary re-renders as it changes often and we only need to recalculate when currency changes.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sortedTransactions, currentGroupBy, report?.reportID, report?.currency, localeCompare, shouldShowGroupedTransactions]);
}, [resolvedTransactions, currentGroupBy, report?.reportID, report?.currency, localeCompare, shouldShowGroupedTransactions]);

const visualOrderTransactionIDs = useMemo(() => {
if (!shouldShowGroupedTransactions || groupedTransactions.length === 0) {
Expand Down Expand Up @@ -492,6 +474,10 @@ function MoneyRequestReportTransactionList({
[translate],
);

const openColumnsPage = useCallback(() => {
Navigation.navigate(ROUTES.REPORT_SETTINGS_COLUMNS.getRoute(report.reportID));
}, [report.reportID]);

const selectedGroupByItem = useMemo(() => groupByItems.find((item) => item.value === currentGroupBy) ?? groupByItems.at(0), [groupByItems, currentGroupBy]);

const groupByOptions = useMemo(
Expand Down Expand Up @@ -576,13 +562,14 @@ function MoneyRequestReportTransactionList({
taxAmountColumnSize={taxAmountColumnSize}
scrollToNewTransaction={transaction.transactionID === newTransactions?.at(0)?.transactionID ? scrollToNewTransaction : undefined}
onArrowRightPress={handleArrowRightPress}
customCardNames={customCardNames}
/>
);
})}
</View>
);
})
: sortedTransactions.map((transaction) => (
: resolvedTransactions.map((transaction) => (
<MoneyRequestReportTransactionItem
key={transaction.transactionID}
transaction={transaction}
Expand All @@ -600,6 +587,7 @@ function MoneyRequestReportTransactionList({
taxAmountColumnSize={taxAmountColumnSize}
scrollToNewTransaction={transaction.transactionID === newTransactions?.at(0)?.transactionID ? scrollToNewTransaction : undefined}
onArrowRightPress={handleArrowRightPress}
customCardNames={customCardNames}
/>
))}
</View>
Expand Down Expand Up @@ -629,7 +617,6 @@ function MoneyRequestReportTransactionList({
sortBy={sortBy}
sortOrder={sortOrder}
columns={columnsToShow}
sortableColumns={sortableColumnNames}
dateColumnSize={dateColumnSize}
amountColumnSize={amountColumnSize}
taxAmountColumnSize={taxAmountColumnSize}
Expand Down Expand Up @@ -675,6 +662,19 @@ function MoneyRequestReportTransactionList({
PopoverComponent={groupByPopoverComponent}
/>
)}
{!shouldUseNarrowLayout && !isExpenseReportViewFromIOUReport && (
<Button
link
small
shouldUseDefaultHover={false}
text={translate('search.columns')}
iconFill={theme.link}
iconHoverFill={theme.linkHover}
icon={expensifyIcons.Columns}
textStyles={[styles.textMicroBold]}
onPress={openColumnsPage}
/>
)}
</View>
{!shouldUseNarrowLayout && !shouldScrollHorizontally && tableHeaderContent}
{shouldScrollHorizontally ? (
Expand Down
4 changes: 3 additions & 1 deletion src/components/Search/FilterDropdowns/SortByPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ function SortByPopup({searchResults, queryJSON, groupBy, onSort, closeOverlay}:
const {clearSelectedTransactions} = useSearchActionsContext();
const [visibleColumns] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, {selector: columnsSelector});
const searchDataType = shouldUseLiveData ? CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT : searchResults?.search?.type;
const currentColumns = !searchResults?.data ? [] : getColumnsToShow(accountID, searchResults?.data, visibleColumns, false, searchDataType, groupBy?.value);
const currentColumns = !searchResults?.data
? []
: getColumnsToShow({currentAccountID: accountID, data: searchResults.data, visibleColumns, type: searchDataType, groupBy: groupBy?.value});
const sortableColumns = getSortByOptions(currentColumns, translate);
const sortBy = {text: translate(getSearchColumnTranslationKey(queryJSON.sortBy)), value: queryJSON.sortBy};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function TransactionGroupListExpanded<TItem extends ListItem>({
if (!transactionsSnapshot?.data) {
currentColumns = [];
} else {
currentColumns = getColumnsToShow(accountID, transactionsSnapshot?.data, visibleColumns, false, transactionsSnapshot?.search.type);
currentColumns = getColumnsToShow({currentAccountID: accountID, data: transactionsSnapshot?.data, visibleColumns, type: transactionsSnapshot?.search.type});
}
}

Expand Down
Loading
Loading