From 685d6a0e5add2461f8d77f8775f6163a7dcbb13f Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 16 Dec 2025 17:38:19 -0700 Subject: [PATCH 1/7] add tax and taxRate --- src/CONST/index.ts | 3 +++ .../SelectionListWithSections/SearchTableHeader.tsx | 6 +++++- src/components/SelectionListWithSections/types.ts | 3 +++ src/components/TransactionItemRow/index.tsx | 12 ++++++++++-- src/libs/SearchUIUtils.ts | 12 ++++++++++++ src/styles/utils/index.ts | 3 +++ 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 3d9c9cb45b31..c3fb7d1a5309 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -6698,6 +6698,8 @@ const CONST = { TAG: this.TABLE_COLUMNS.TAG, REIMBURSABLE: this.TABLE_COLUMNS.REIMBURSABLE, BILLABLE: this.TABLE_COLUMNS.BILLABLE, + TAX_RATE: this.TABLE_COLUMNS.TAX_RATE, + TAX_AMOUNT: this.TABLE_COLUMNS.TAX_AMOUNT, STATUS: this.TABLE_COLUMNS.STATUS, TITLE: this.TABLE_COLUMNS.TITLE, ACTION: this.TABLE_COLUMNS.ACTION, @@ -6794,6 +6796,7 @@ const CONST = { TAG: 'tag', REIMBURSABLE: 'reimbursable', BILLABLE: 'billable', + TAX_RATE: 'taxrate', TOTAL_AMOUNT: 'amount', TOTAL: 'total', TYPE: 'type', diff --git a/src/components/SelectionListWithSections/SearchTableHeader.tsx b/src/components/SelectionListWithSections/SearchTableHeader.tsx index 89babdedeb5d..40cab6a21b3a 100644 --- a/src/components/SelectionListWithSections/SearchTableHeader.tsx +++ b/src/components/SelectionListWithSections/SearchTableHeader.tsx @@ -97,7 +97,11 @@ const getExpenseHeaders = (groupBy?: SearchGroupBy): SearchColumnConfig[] => [ { columnName: CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT, translationKey: 'common.tax', - isColumnSortable: false, + canBeMissing: true, + }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.TAX_RATE, + translationKey: 'iou.taxRate', canBeMissing: true, }, { diff --git a/src/components/SelectionListWithSections/types.ts b/src/components/SelectionListWithSections/types.ts index 6f9e89a728ec..ccf451e374a5 100644 --- a/src/components/SelectionListWithSections/types.ts +++ b/src/components/SelectionListWithSections/types.ts @@ -332,6 +332,9 @@ type TransactionListItemType = ListItem & /** The main action that can be performed for the transaction */ action: SearchTransactionAction; + + /** The tax code of the transaction */ + taxCode?: string; }; type ReportActionListItemType = ListItem & diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 329ee0aa0be8..6f7e032a90df 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -429,9 +429,17 @@ function TransactionItemRow({ /> ), - [CONST.SEARCH.TABLE_COLUMNS.TAX]: ( + [CONST.SEARCH.TABLE_COLUMNS.TAX_RATE]: ( + {'100'} + + ), + [CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT]: ( + { + const aValue = `${a.policy?.taxRates?.taxes?.[a.taxCode ?? '']?.name ?? ''} (${a.policy?.taxRates?.taxes?.[a.taxCode ?? '']?.value ?? ''})`; + const bValue = `${b.policy?.taxRates?.taxes?.[b.taxCode ?? '']?.name ?? ''} (${b.policy?.taxRates?.taxes?.[b.taxCode ?? '']?.value ?? ''})`; + return compareValues(aValue, bValue, sortOrder, sortBy, localeCompare); + }); + } + if (!sortingProperty) { return data; } @@ -2297,6 +2305,10 @@ function getSearchColumnTranslationKey(columnId: SearchCustomColumnIds): Transla return 'common.title'; case CONST.SEARCH.TABLE_COLUMNS.STATUS: return 'common.status'; + case CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT: + return 'common.tax'; + case CONST.SEARCH.TABLE_COLUMNS.TAX_RATE: + return 'iou.taxRate'; } } diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index ad0a69a8b65f..d82dfbfc068c 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -1775,6 +1775,9 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ case CONST.SEARCH.TABLE_COLUMNS.BILLABLE: columnWidth = {...getWidthStyle(variables.w92)}; break; + case CONST.SEARCH.TABLE_COLUMNS.TAX_RATE: + columnWidth = {...getWidthStyle(variables.w92)}; + break; case CONST.SEARCH.TABLE_COLUMNS.ACTION: columnWidth = {...getWidthStyle(variables.w80), ...styles.alignItemsCenter}; break; From 5583edd95acca02d87b80655100ffc8c5e1840bd Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 16 Dec 2025 17:43:03 -0700 Subject: [PATCH 2/7] fix sorting for tax amount --- src/libs/SearchUIUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index e90bd28ba87d..dce1aadc53d7 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -150,7 +150,7 @@ const transactionColumnNamesToSortingProperty: TransactionSorting = { [CONST.SEARCH.TABLE_COLUMNS.TYPE]: null, [CONST.SEARCH.TABLE_COLUMNS.ACTION]: 'action' as const, [CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION]: 'comment' as const, - [CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT]: null, + [CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT]: 'taxAmount' as const, [CONST.SEARCH.TABLE_COLUMNS.RECEIPT]: null, }; From 8d51900da00f197c20838546c1bde48b10c35755 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 16 Dec 2025 17:44:44 -0700 Subject: [PATCH 3/7] fix order --- .../SelectionListWithSections/SearchTableHeader.tsx | 8 ++++---- src/libs/SearchUIUtils.ts | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/SelectionListWithSections/SearchTableHeader.tsx b/src/components/SelectionListWithSections/SearchTableHeader.tsx index 40cab6a21b3a..48abbd7cdae0 100644 --- a/src/components/SelectionListWithSections/SearchTableHeader.tsx +++ b/src/components/SelectionListWithSections/SearchTableHeader.tsx @@ -95,13 +95,13 @@ const getExpenseHeaders = (groupBy?: SearchGroupBy): SearchColumnConfig[] => [ translationKey: 'common.withdrawalID', }, { - columnName: CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT, - translationKey: 'common.tax', + columnName: CONST.SEARCH.TABLE_COLUMNS.TAX_RATE, + translationKey: 'iou.taxRate', canBeMissing: true, }, { - columnName: CONST.SEARCH.TABLE_COLUMNS.TAX_RATE, - translationKey: 'iou.taxRate', + columnName: CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT, + translationKey: 'common.tax', canBeMissing: true, }, { diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index dce1aadc53d7..c65d02c858f0 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -2770,6 +2770,7 @@ function getColumnsToShow( [CONST.SEARCH.TABLE_COLUMNS.TAG]: false, [CONST.SEARCH.TABLE_COLUMNS.REIMBURSABLE]: false, [CONST.SEARCH.TABLE_COLUMNS.BILLABLE]: false, + [CONST.SEARCH.TABLE_COLUMNS.TAX_RATE]: false, [CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT]: false, [CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: true, [CONST.SEARCH.TABLE_COLUMNS.TITLE]: false, From 6fb1848d49e1792593347edde8e3143e8602b12c Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 16 Dec 2025 17:53:09 -0700 Subject: [PATCH 4/7] use method --- src/components/TransactionItemRow/index.tsx | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 6f7e032a90df..a174f1eed72c 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -34,7 +34,7 @@ import { } from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; -import type {PersonalDetails, Report, TransactionViolation} from '@src/types/onyx'; +import type {PersonalDetails, Report, TransactionViolation, Policy} from '@src/types/onyx'; import type {SearchTransactionAction} from '@src/types/onyx/SearchResults'; import CategoryCell from './DataCells/CategoryCell'; import ChatBubbleCell from './DataCells/ChatBubbleCell'; @@ -82,6 +82,9 @@ type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & { /** Report to which the transaction belongs */ report?: Report; + + /** Policy to which the transaction belongs */ + policy?: Policy; }; type TransactionItemRowProps = { @@ -186,6 +189,21 @@ function TransactionItemRow({ const merchant = useMemo(() => getMerchantName(transactionItem, translate), [transactionItem, translate]); const description = getDescription(transactionItem); + const formattedTaxRate = useMemo(() => { + const taxRateName = transactionItem?.policy?.taxRates?.taxes?.[transactionItem.taxCode ?? '']?.name ?? ''; + const taxRateValue = transactionItem?.policy?.taxRates?.taxes?.[transactionItem.taxCode ?? '']?.value ?? ''; + + if (!taxRateName && !taxRateValue) { + return ''; + } + + if (!taxRateValue) { + return taxRateName; + } + + return `${taxRateName} (${taxRateValue})`; + }, [transactionItem?.policy?.taxRates?.taxes, transactionItem.taxCode]); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const merchantOrDescription = merchant || description; @@ -434,7 +452,7 @@ function TransactionItemRow({ key={CONST.SEARCH.TABLE_COLUMNS.TAX_RATE} style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.TAX_RATE)]} > - {'100'} + {formattedTaxRate} ), [CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT]: ( From a9582a45c34bd4d8d4401095b3427a1729196e5c Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 16 Dec 2025 18:06:02 -0700 Subject: [PATCH 5/7] add to dependency array --- src/components/TransactionItemRow/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index a174f1eed72c..cccdd6065bcd 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -509,6 +509,7 @@ function TransactionItemRow({ isAmountColumnWide, isTaxAmountColumnWide, isLargeScreenWidth, + formattedTaxRate, ], ); const shouldRenderChatBubbleCell = useMemo(() => { From d0cb0ed1b4f06b4b5669d590ae9f662841616b8c Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 17 Dec 2025 10:55:39 -0700 Subject: [PATCH 6/7] use textcell, fix style --- src/components/TransactionItemRow/index.tsx | 2 +- src/styles/utils/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 7229a2e1bcbc..166198c12604 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -477,7 +477,7 @@ function TransactionItemRow({ key={CONST.SEARCH.TABLE_COLUMNS.TAX_RATE} style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.TAX_RATE)]} > - {formattedTaxRate} + ), [CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT]: ( diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index b38aaa401678..11b5cd7891ee 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -1777,7 +1777,7 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ columnWidth = {...getWidthStyle(variables.w92)}; break; case CONST.SEARCH.TABLE_COLUMNS.TAX_RATE: - columnWidth = {...getWidthStyle(variables.w92)}; + columnWidth = {...getWidthStyle(variables.w92), ...styles.flex1}; break; case CONST.SEARCH.TABLE_COLUMNS.ACTION: columnWidth = {...getWidthStyle(variables.w80), ...styles.alignItemsCenter}; From 305da9f555a1475bbabc1c8df50ea6382dfb960c Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 17 Dec 2025 11:00:25 -0700 Subject: [PATCH 7/7] fix prettier --- src/components/TransactionItemRow/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 166198c12604..51b9a6f69a6c 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -38,7 +38,7 @@ import { } from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; -import type {PersonalDetails, Report, TransactionViolation, Policy} from '@src/types/onyx'; +import type {PersonalDetails, Policy, Report, TransactionViolation} from '@src/types/onyx'; import type {SearchTransactionAction} from '@src/types/onyx/SearchResults'; import CategoryCell from './DataCells/CategoryCell'; import ChatBubbleCell from './DataCells/ChatBubbleCell';