From 5f8b43444246709c6ce44ec71c79b0fffd306144 Mon Sep 17 00:00:00 2001 From: X Developer Date: Tue, 30 Jun 2026 08:24:55 +0430 Subject: [PATCH 1/5] fix: default report view to editable amount column --- src/libs/SearchUIUtils.ts | 27 ++++--- .../Report/ReportDetailsColumnsPage.tsx | 4 +- tests/unit/Search/SearchUIUtilsTest.ts | 75 +++++++++++++++---- 3 files changed, 75 insertions(+), 31 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index cc91dc6de32e..a34f1089e36d 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -5747,9 +5747,9 @@ function getColumnsToShow({ [CONST.SEARCH.TABLE_COLUMNS.ORIGINAL_AMOUNT]: false, [CONST.SEARCH.TABLE_COLUMNS.REIMBURSABLE]: shouldShowReimbursableColumn, [CONST.SEARCH.TABLE_COLUMNS.BILLABLE]: shouldShowBillableColumn, - [CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: false, [CONST.SEARCH.TABLE_COLUMNS.COMMENTS]: shouldShowCommentsColumn, - [CONST.SEARCH.TABLE_COLUMNS.TOTAL]: true, + [CONST.SEARCH.TABLE_COLUMNS.TOTAL]: false, + [CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: true, } : { [CONST.SEARCH.TABLE_COLUMNS.AVATAR]: true, @@ -5817,11 +5817,12 @@ function getColumnsToShow({ } if (shouldShowCommentsColumn && !addedColumns.has(CONST.SEARCH.TABLE_COLUMNS.COMMENTS)) { - const totalIndex = result.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL); - if (totalIndex === -1) { + const moneyColumnIndexes = [result.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT), result.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL)].filter((index) => index !== -1); + const moneyColumnIndex = moneyColumnIndexes.length > 0 ? Math.min(...moneyColumnIndexes) : -1; + if (moneyColumnIndex === -1) { result.push(CONST.SEARCH.TABLE_COLUMNS.COMMENTS); } else { - result.splice(totalIndex, 0, CONST.SEARCH.TABLE_COLUMNS.COMMENTS); + result.splice(moneyColumnIndex, 0, CONST.SEARCH.TABLE_COLUMNS.COMMENTS); } } @@ -5926,14 +5927,13 @@ function getColumnsToShow({ if (hasExchangeRate) { columns[CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE] = true; } - // Expense report view: TOTAL (workspace currency) is always shown when a conversion - // exists. ORIGINAL_AMOUNT (the transaction's original/foreign amount) is a separate, - // user-selectable report column — in the report view it's gated behind an explicit - // selection (customResult) so it never renders by default, only when the user picks it. + // Expense report view: TOTAL_AMOUNT (transaction amount) is shown by default. TOTAL + // (workspace currency) is added when a conversion exists. ORIGINAL_AMOUNT is gated + // behind an explicit report-column selection so it never renders by default. // Search page: ORIGINAL_AMOUNT stays data-driven (shown whenever a conversion exists). if (hasExchangeRate) { if (isExpenseReportView) { - columns[CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT] = true; + columns[CONST.SEARCH.TABLE_COLUMNS.TOTAL] = true; if (customResult) { columns[CONST.SEARCH.TABLE_COLUMNS.ORIGINAL_AMOUNT] = true; } @@ -6026,10 +6026,9 @@ function getColumnsToShow({ CONST.SEARCH.TABLE_COLUMNS.TYPE, CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.STATUS, - // TOTAL_AMOUNT (Amount) is data-driven in expense report view: shown only when a - // conversion exists. In search view, TOTAL_AMOUNT is always-true via the default - // columns map, so we don't need to list it here as non-data for either surface. - CONST.SEARCH.TABLE_COLUMNS.TOTAL, + // TOTAL_AMOUNT (Amount) is the always-present report-view money column. TOTAL is + // data-driven and only appears when a conversion exists. + CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT, CONST.SEARCH.TABLE_COLUMNS.COMMENTS, CONST.SEARCH.TABLE_COLUMNS.REIMBURSABLE, CONST.SEARCH.TABLE_COLUMNS.BILLABLE, diff --git a/src/pages/settings/Report/ReportDetailsColumnsPage.tsx b/src/pages/settings/Report/ReportDetailsColumnsPage.tsx index 91eccdaeffbc..0778fe03c0fb 100644 --- a/src/pages/settings/Report/ReportDetailsColumnsPage.tsx +++ b/src/pages/settings/Report/ReportDetailsColumnsPage.tsx @@ -30,7 +30,7 @@ const REPORT_DETAILS_DEFAULT_COLUMNS: SearchCustomColumnIds[] = [ CONST.SEARCH.TABLE_COLUMNS.MERCHANT, CONST.SEARCH.TABLE_COLUMNS.CATEGORY, CONST.SEARCH.TABLE_COLUMNS.TAG, - CONST.SEARCH.TABLE_COLUMNS.TOTAL, + CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT, ]; function ReportDetailsColumnsPage() { @@ -91,7 +91,7 @@ function ReportDetailsColumnsPage() { return visibleColumns.filter((col) => allTypeCustomColumns.includes(col as SearchCustomColumnIds)) as SearchCustomColumnIds[]; }, [reportDetailsColumns, reportTransactions, currentUserDetails?.accountID, report, policy, policyCategories, allTypeCustomColumns]); - const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.TOTAL]); + const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]); const handleSave = (selectedColumnIds: SearchCustomColumnIds[]) => { // Skip saving if columns haven't changed from the effective state, to avoid diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index e86a0caf4a78..b2cc0127cb56 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -8782,7 +8782,7 @@ describe('SearchUIUtils', () => { // Column order: after Tag and before Amount (and before Comments) expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TAG)).toBeLessThan(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.REIMBURSABLE)); expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.REIMBURSABLE)).toBeLessThan(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.BILLABLE)); - expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.BILLABLE)).toBeLessThan(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL)); + expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.BILLABLE)).toBeLessThan(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT)); }); test('Should not include Reimbursable column in expense report view when all expenses are reimbursable', () => { @@ -8847,16 +8847,19 @@ describe('SearchUIUtils', () => { expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.TAG); }); - test('Should place COMMENTS right before TOTAL in expense report view with custom columns', () => { + test('Should place COMMENTS right before AMOUNT in expense report view with custom columns', () => { const baseTransaction = searchResults.data[`transactions_${transactionID}`]; const testTransaction = { ...baseTransaction, transactionID: 'test', merchant: 'Test Merchant', + groupExchangeRate: undefined, + currencyConversionRate: undefined, + convertedAmount: undefined, }; // Use custom columns to trigger the custom columns path - const visibleColumns = [CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.TOTAL]; + const visibleColumns = [CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]; const columns = SearchUIUtils.getColumnsToShow({ currentAccountID: submitterAccountID, data: [testTransaction], @@ -8866,17 +8869,20 @@ describe('SearchUIUtils', () => { }); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.COMMENTS); - // TOTAL should be at the end, with COMMENTS immediately before it + // AMOUNT should be at the end, with COMMENTS immediately before it expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.COMMENTS)).toBe(columns.length - 2); - expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL)).toBe(columns.length - 1); + expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT)).toBe(columns.length - 1); }); - test('Should place COMMENTS right before TOTAL in default expense report view', () => { + test('Should place COMMENTS right before AMOUNT in default expense report view', () => { const baseTransaction = searchResults.data[`transactions_${transactionID}`]; const testTransaction = { ...baseTransaction, transactionID: 'test', merchant: 'Test Merchant', + groupExchangeRate: undefined, + currencyConversionRate: undefined, + convertedAmount: undefined, }; const columns = SearchUIUtils.getColumnsToShow({ @@ -8887,7 +8893,7 @@ describe('SearchUIUtils', () => { }); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.COMMENTS); - expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.COMMENTS)).toBe(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL) - 1); + expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.COMMENTS)).toBe(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT) - 1); }); test('Should not duplicate COMMENTS column when already in visible columns', () => { @@ -8928,9 +8934,9 @@ describe('SearchUIUtils', () => { // EXCHANGE_RATE should be hidden because no transaction has exchange rate data expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE); - // Always-shown columns should still be present + // Always-shown columns should still be present; TOTAL is conversion-driven and hidden here expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.DATE); - expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); + expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); }); test('Should show EXCHANGE_RATE column when transaction has exchange rate data', () => { @@ -9177,22 +9183,42 @@ describe('SearchUIUtils', () => { expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT); }); - test('Should hide empty AMOUNT column in expense report view when no conversion', () => { + test('Should show AMOUNT by default and hide TOTAL in expense report view when no conversion', () => { const baseTransaction = searchResults.data[`transactions_${transactionID}`]; const testTransaction = { ...baseTransaction, transactionID: 'test', merchant: 'Test Merchant', + groupExchangeRate: undefined, + currencyConversionRate: undefined, + convertedAmount: undefined, + }; + + const columns = SearchUIUtils.getColumnsToShow({currentAccountID: submitterAccountID, data: [testTransaction], visibleColumns: [], isExpenseReportView: true}); + + expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); + expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); + }); + + test('Should hide TOTAL from custom expense report columns when there is no conversion', () => { + const baseTransaction = searchResults.data[`transactions_${transactionID}`]; + const testTransaction = { + ...baseTransaction, + transactionID: 'test', + merchant: 'Test Merchant', + groupExchangeRate: undefined, + currencyConversionRate: undefined, convertedAmount: undefined, }; const visibleColumns = [CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.TOTAL, CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]; const columns = SearchUIUtils.getColumnsToShow({currentAccountID: submitterAccountID, data: [testTransaction], visibleColumns, isExpenseReportView: true}); - expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); + expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); + expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); }); - test('Should show AMOUNT column when transaction has a real conversion (currencies differ)', () => { + test('Should show TOTAL from custom expense report columns when there is a conversion', () => { const baseTransaction = searchResults.data[`transactions_${transactionID}`]; const testTransaction = { ...baseTransaction, @@ -9208,6 +9234,25 @@ describe('SearchUIUtils', () => { const columns = SearchUIUtils.getColumnsToShow({currentAccountID: submitterAccountID, data: [testTransaction], visibleColumns, isExpenseReportView: true}); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); + expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); + }); + + test('Should show AMOUNT and TOTAL by default when transaction has a real conversion (currencies differ)', () => { + const baseTransaction = searchResults.data[`transactions_${transactionID}`]; + const testTransaction = { + ...baseTransaction, + transactionID: 'test', + merchant: 'Test Merchant', + currency: 'EUR', + groupCurrency: 'USD', + groupExchangeRate: 1.1, + convertedAmount: 2500, + }; + + const columns = SearchUIUtils.getColumnsToShow({currentAccountID: submitterAccountID, data: [testTransaction], visibleColumns: [], isExpenseReportView: true}); + + expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); + expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); }); test('Should show column if at least one transaction has data for it', () => { @@ -9237,7 +9282,7 @@ describe('SearchUIUtils', () => { expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.TAX_RATE); }); - test('Should always show RECEIPT, TYPE, DATE, TOTAL in custom columns regardless of data, and COMMENTS when shouldShowCommentsColumn is true', () => { + test('Should always show RECEIPT, TYPE, DATE, AMOUNT in custom columns regardless of data, and COMMENTS when shouldShowCommentsColumn is true', () => { const baseTransaction = searchResults.data[`transactions_${transactionID}`]; const testTransaction = { ...baseTransaction, @@ -9246,7 +9291,7 @@ describe('SearchUIUtils', () => { modifiedMerchant: '', }; - const visibleColumns = [CONST.SEARCH.TABLE_COLUMNS.RECEIPT, CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.MERCHANT, CONST.SEARCH.TABLE_COLUMNS.TOTAL]; + const visibleColumns = [CONST.SEARCH.TABLE_COLUMNS.RECEIPT, CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.MERCHANT, CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]; const columns = SearchUIUtils.getColumnsToShow({ currentAccountID: submitterAccountID, data: [testTransaction], @@ -9258,7 +9303,7 @@ describe('SearchUIUtils', () => { // Always-shown columns should be present expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.RECEIPT); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.DATE); - expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); + expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TYPE); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.COMMENTS); // MERCHANT should be hidden because no data From ef1bf95d9134056cb1a3f085c35bebbfa317a0a8 Mon Sep 17 00:00:00 2001 From: X Developer Date: Wed, 1 Jul 2026 16:16:28 +0430 Subject: [PATCH 2/5] fix: adjust column order for total and total amount --- src/libs/SearchUIUtils.ts | 2 +- tests/unit/Search/SearchUIUtilsTest.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index c4ce194593ba..f08774343290 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -5822,8 +5822,8 @@ function getColumnsToShow({ [CONST.SEARCH.TABLE_COLUMNS.REIMBURSABLE]: shouldShowReimbursableColumn, [CONST.SEARCH.TABLE_COLUMNS.BILLABLE]: shouldShowBillableColumn, [CONST.SEARCH.TABLE_COLUMNS.COMMENTS]: shouldShowCommentsColumn, - [CONST.SEARCH.TABLE_COLUMNS.TOTAL]: false, [CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: true, + [CONST.SEARCH.TABLE_COLUMNS.TOTAL]: false, } : { [CONST.SEARCH.TABLE_COLUMNS.AVATAR]: true, diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index aa60bbf6d109..74f22bbcacdf 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -9284,7 +9284,7 @@ describe('SearchUIUtils', () => { convertedAmount: undefined, }; - const visibleColumns = [CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.TOTAL, CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]; + const visibleColumns = [CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT, CONST.SEARCH.TABLE_COLUMNS.TOTAL]; const columns = SearchUIUtils.getColumnsToShow({currentAccountID: submitterAccountID, data: [testTransaction], visibleColumns, isExpenseReportView: true}); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); @@ -9303,11 +9303,12 @@ describe('SearchUIUtils', () => { convertedAmount: 2500, }; - const visibleColumns = [CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.TOTAL, CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]; + const visibleColumns = [CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT, CONST.SEARCH.TABLE_COLUMNS.TOTAL]; const columns = SearchUIUtils.getColumnsToShow({currentAccountID: submitterAccountID, data: [testTransaction], visibleColumns, isExpenseReportView: true}); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); + expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT)).toBeLessThan(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL)); }); test('Should show AMOUNT and TOTAL by default when transaction has a real conversion (currencies differ)', () => { @@ -9326,6 +9327,7 @@ describe('SearchUIUtils', () => { expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); + expect(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT)).toBeLessThan(columns.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL)); }); test('Should show selected columns regardless of whether any transaction has data for them', () => { From fb77db83660c9b4dfea83ab3858907b88649ed19 Mon Sep 17 00:00:00 2001 From: X Developer Date: Fri, 3 Jul 2026 17:19:41 +0430 Subject: [PATCH 3/5] fix: simplify comments placement and preserve custom report columns --- src/libs/SearchUIUtils.ts | 23 ++++++++--------------- tests/unit/Search/SearchUIUtilsTest.ts | 4 ++-- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index ebdba33055c8..48119aaa69de 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -5889,12 +5889,11 @@ function getColumnsToShow({ } if (shouldShowCommentsColumn && !addedColumns.has(CONST.SEARCH.TABLE_COLUMNS.COMMENTS)) { - const moneyColumnIndexes = [result.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT), result.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL)].filter((index) => index !== -1); - const moneyColumnIndex = moneyColumnIndexes.length > 0 ? Math.min(...moneyColumnIndexes) : -1; - if (moneyColumnIndex === -1) { + const totalAmountIndex = result.indexOf(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); + if (totalAmountIndex === -1) { result.push(CONST.SEARCH.TABLE_COLUMNS.COMMENTS); } else { - result.splice(moneyColumnIndex, 0, CONST.SEARCH.TABLE_COLUMNS.COMMENTS); + result.splice(totalAmountIndex, 0, CONST.SEARCH.TABLE_COLUMNS.COMMENTS); } } @@ -5993,16 +5992,10 @@ function getColumnsToShow({ if (hasExchangeRate) { columns[CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE] = true; } - // Expense report view: TOTAL_AMOUNT (transaction amount) is shown by default. TOTAL - // (workspace currency) is added when a conversion exists. ORIGINAL_AMOUNT never - // renders by default in report view because it must be explicitly selected. - // Search page: ORIGINAL_AMOUNT stays data-driven (shown whenever a conversion exists). - if (hasExchangeRate) { - if (isExpenseReportView) { - columns[CONST.SEARCH.TABLE_COLUMNS.TOTAL] = true; - } else { - columns[CONST.SEARCH.TABLE_COLUMNS.ORIGINAL_AMOUNT] = true; - } + // Expense report view: TOTAL_AMOUNT (transaction amount) is shown by default. + // TOTAL (workspace currency) is added when a conversion exists. + if (hasExchangeRate && isExpenseReportView) { + columns[CONST.SEARCH.TABLE_COLUMNS.TOTAL] = true; } if (!Array.isArray(data)) { @@ -6073,7 +6066,7 @@ function getColumnsToShow({ } if (customResult) { - return customResult.filter((col) => col !== CONST.SEARCH.TABLE_COLUMNS.TOTAL || columns[CONST.SEARCH.TABLE_COLUMNS.TOTAL]); + return customResult; } return (Object.keys(columns) as SearchColumnType[]).filter((col) => columns[col]); diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 55e8be095ba4..00b3961faf1f 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -9325,7 +9325,7 @@ describe('SearchUIUtils', () => { expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); }); - test('Should hide TOTAL from custom expense report columns when there is no conversion', () => { + test('Should show selected TOTAL from custom expense report columns when there is no conversion', () => { const baseTransaction = searchResults.data[`transactions_${transactionID}`]; const testTransaction = { ...baseTransaction, @@ -9340,7 +9340,7 @@ describe('SearchUIUtils', () => { const columns = SearchUIUtils.getColumnsToShow({currentAccountID: submitterAccountID, data: [testTransaction], visibleColumns, isExpenseReportView: true}); expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT); - expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); + expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); }); test('Should show TOTAL from custom expense report columns when there is a conversion', () => { From d6c3ebe8864a9c4383e167f267c2bd08affec1e3 Mon Sep 17 00:00:00 2001 From: X Developer Date: Fri, 3 Jul 2026 17:30:17 +0430 Subject: [PATCH 4/5] fix: update column visibility logic to include TOTAL in custom report --- tests/unit/Search/SearchUIUtilsTest.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 00b3961faf1f..f2726ae9bff0 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -9057,9 +9057,9 @@ describe('SearchUIUtils', () => { // EXCHANGE_RATE is selected, so it shows even when no transaction has exchange rate data expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE); - // Always-shown columns should still be present; TOTAL is conversion-driven and hidden here + // Selected custom columns should still be present expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.DATE); - expect(columns).not.toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); + expect(columns).toContain(CONST.SEARCH.TABLE_COLUMNS.TOTAL); }); test('Should show EXCHANGE_RATE column when transaction has exchange rate data', () => { From 8d45c37764e12e49830cbcf93524d2be444e162d Mon Sep 17 00:00:00 2001 From: X Developer Date: Mon, 6 Jul 2026 09:29:08 +0430 Subject: [PATCH 5/5] fix: remove redundant comments --- src/libs/SearchUIUtils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index e41083a8c9a9..a29091e8fa33 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -6028,8 +6028,6 @@ function getColumnsToShow({ if (hasExchangeRate) { columns[CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE] = true; } - // Expense report view: TOTAL_AMOUNT (transaction amount) is shown by default. - // TOTAL (workspace currency) is added when a conversion exists. if (hasExchangeRate && isExpenseReportView) { columns[CONST.SEARCH.TABLE_COLUMNS.TOTAL] = true; }