From 54f7f8485688bb9e6afeef70fa07175dcf4347b0 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 15 Dec 2025 14:26:34 -0700 Subject: [PATCH 1/8] add approved date --- src/CONST/index.ts | 2 ++ src/components/Search/index.tsx | 3 ++- src/libs/SearchUIUtils.ts | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 2a2932c072fa..a9b055984e10 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1381,6 +1381,7 @@ const CONST = { RECEIPT: 'receipt', DATE: 'date', SUBMITTED: 'submitted', + APPROVED: 'approved', MERCHANT: 'merchant', DESCRIPTION: 'description', FROM: 'from', @@ -6747,6 +6748,7 @@ const CONST = { RECEIPT: 'receipt', DATE: 'date', SUBMITTED: 'submitted', + APPROVED: 'approved', MERCHANT: 'merchant', DESCRIPTION: 'description', FROM: 'from', diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index e1e248ba7bdf..e8bd4204a5ae 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -1034,7 +1034,7 @@ function Search({ navigation.setParams({q: newQuery, rawQuery: undefined}); }; - const {shouldShowYearCreated, shouldShowYearSubmitted} = shouldShowYearUtil(searchResults?.data, isExpenseReportType ?? false); + const {shouldShowYearCreated, shouldShowYearSubmitted, shouldShowYearApproved} = shouldShowYearUtil(searchResults?.data, isExpenseReportType ?? false); const {shouldShowAmountInWideColumn, shouldShowTaxAmountInWideColumn} = getWideAmountIndicators(searchResults?.data); const shouldShowSorting = !validGroupBy; const shouldShowTableHeader = isLargeScreenWidth && !isChat && !validGroupBy; @@ -1066,6 +1066,7 @@ function Search({ sortBy={sortBy} shouldShowYear={shouldShowYearCreated} shouldShowYearSubmitted={shouldShowYearSubmitted} + shouldShowYearApproved={shouldShowYearApproved} isAmountColumnWide={shouldShowAmountInWideColumn} isTaxAmountColumnWide={shouldShowTaxAmountInWideColumn} shouldShowSorting={shouldShowSorting} diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 20a3c3fa4744..634572fbd41c 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -851,6 +851,7 @@ function getWideAmountIndicators(data: TransactionListItemType[] | TransactionGr type ShouldShowYearResult = { shouldShowYearCreated: boolean; shouldShowYearSubmitted: boolean; + shouldShowYearApproved: boolean; }; /** @@ -866,6 +867,7 @@ function shouldShowYear( const result: ShouldShowYearResult = { shouldShowYearCreated: false, shouldShowYearSubmitted: false, + shouldShowYearApproved: false, }; const currentYear = new Date().getFullYear(); @@ -885,6 +887,9 @@ function shouldShowYear( if (item.submitted && DateUtils.doesDateBelongToAPastYear(item.submitted)) { result.shouldShowYearSubmitted = true; } + if (item.approved && DateUtils.doesDateBelongToAPastYear(item.approved)) { + result.shouldShowYearApproved = true; + } } if (isTransactionListItemType(item)) { const transactionCreated = getTransactionCreatedDate(item); @@ -894,6 +899,9 @@ function shouldShowYear( if (item.submitted && DateUtils.doesDateBelongToAPastYear(item.submitted)) { result.shouldShowYearSubmitted = true; } + if (item.approved && DateUtils.doesDateBelongToAPastYear(item.approved)) { + result.shouldShowYearApproved = true; + } } // Early exit if all flags are true @@ -914,6 +922,9 @@ function shouldShowYear( if (report?.submitted && DateUtils.doesDateBelongToAPastYear(report.submitted)) { result.shouldShowYearSubmitted = true; } + if (report?.approved && DateUtils.doesDateBelongToAPastYear(report.approved)) { + result.shouldShowYearApproved = true; + } } else if (!checkOnlyReports && isReportActionEntry(key)) { const item = data[key]; for (const action of Object.values(item)) { @@ -931,6 +942,9 @@ function shouldShowYear( if (item.submitted && DateUtils.doesDateBelongToAPastYear(item.submitted)) { result.shouldShowYearSubmitted = true; } + if (item.approved && DateUtils.doesDateBelongToAPastYear(item.approved)) { + result.shouldShowYearApproved = true; + } } // Early exit if all flags are true From 97ce2087795c5ea35dd0be1ef7c505bcaef03051 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 15 Dec 2025 14:28:14 -0700 Subject: [PATCH 2/8] prop drill --- .../Search/ExpenseReportListItemRow.tsx | 7 +++++++ .../Search/TransactionListItem.tsx | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx index b8d618276532..9dc7bb719d4b 100644 --- a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx +++ b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx @@ -165,6 +165,13 @@ function ExpenseReportListItemRow({ isLargeScreenWidth /> + + + ({ backgroundColor: theme.highlightBG, }); - const {amountColumnSize, dateColumnSize, taxAmountColumnSize, submittedColumnSize} = useMemo(() => { + const {amountColumnSize, dateColumnSize, taxAmountColumnSize, submittedColumnSize, approvedColumnSize} = useMemo(() => { return { amountColumnSize: transactionItem.isAmountColumnWide ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL, taxAmountColumnSize: transactionItem.isTaxAmountColumnWide ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL, dateColumnSize: transactionItem.shouldShowYear ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL, submittedColumnSize: transactionItem.shouldShowYearSubmitted ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL, + approvedColumnSize: transactionItem.shouldShowYearApproved ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL, }; - }, [transactionItem.isAmountColumnWide, transactionItem.isTaxAmountColumnWide, transactionItem.shouldShowYear, transactionItem.shouldShowYearSubmitted]); + }, [transactionItem.isAmountColumnWide, transactionItem.isTaxAmountColumnWide, transactionItem.shouldShowYear, transactionItem.shouldShowYearSubmitted, transactionItem.shouldShowYearApproved]); const transactionViolations = useMemo(() => { return (violations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionItem.transactionID}`] ?? []).filter( @@ -203,6 +204,7 @@ function TransactionListItem({ isSelected={!!transactionItem.isSelected} dateColumnSize={dateColumnSize} submittedColumnSize={submittedColumnSize} + approvedColumnSize={approvedColumnSize} amountColumnSize={amountColumnSize} taxAmountColumnSize={taxAmountColumnSize} shouldShowCheckbox={!!canSelectMultiple} From 12125edb825b596fb9ada2b14782241522719657 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 15 Dec 2025 14:34:57 -0700 Subject: [PATCH 3/8] more changes --- .../SearchTableHeader.tsx | 11 +++++++++++ .../SortableTableHeader.tsx | 3 +++ .../SelectionListWithSections/types.ts | 14 ++++++++++++++ src/components/TransactionItemRow/index.tsx | 18 +++++++++++++++++- src/libs/DebugUtils.ts | 2 ++ 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/components/SelectionListWithSections/SearchTableHeader.tsx b/src/components/SelectionListWithSections/SearchTableHeader.tsx index c7d112b8c29e..61681e6081d6 100644 --- a/src/components/SelectionListWithSections/SearchTableHeader.tsx +++ b/src/components/SelectionListWithSections/SearchTableHeader.tsx @@ -38,6 +38,10 @@ const getExpenseHeaders = (groupBy?: SearchGroupBy): SearchColumnConfig[] => [ columnName: CONST.SEARCH.TABLE_COLUMNS.SUBMITTED, translationKey: 'common.submitted', }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.APPROVED, + translationKey: 'search.filters.approved', + }, { columnName: CONST.SEARCH.TABLE_COLUMNS.MERCHANT, translationKey: 'common.merchant', @@ -148,6 +152,10 @@ const getExpenseReportHeaders = (profileIcon?: IconAsset): SearchColumnConfig[] columnName: CONST.SEARCH.TABLE_COLUMNS.SUBMITTED, translationKey: 'common.submitted', }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.APPROVED, + translationKey: 'search.filters.approved', + }, { columnName: CONST.SEARCH.TABLE_COLUMNS.STATUS, translationKey: 'common.status', @@ -201,6 +209,7 @@ type SearchTableHeaderProps = { onSortPress: (column: SearchColumnType, order: SortOrder) => void; shouldShowYear: boolean; shouldShowYearSubmitted?: boolean; + shouldShowYearApproved?: boolean; isAmountColumnWide: boolean; isTaxAmountColumnWide: boolean; shouldShowSorting: boolean; @@ -217,6 +226,7 @@ function SearchTableHeader({ onSortPress, shouldShowYear, shouldShowYearSubmitted, + shouldShowYearApproved, shouldShowSorting, canSelectMultiple, isAmountColumnWide, @@ -256,6 +266,7 @@ function SearchTableHeader({ shouldShowColumn={shouldShowColumn} dateColumnSize={shouldShowYear ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL} submittedColumnSize={shouldShowYearSubmitted ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL} + approvedColumnSize={shouldShowYearApproved ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL} amountColumnSize={isAmountColumnWide ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL} taxAmountColumnSize={isTaxAmountColumnWide ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL} shouldShowSorting={shouldShowSorting} diff --git a/src/components/SelectionListWithSections/SortableTableHeader.tsx b/src/components/SelectionListWithSections/SortableTableHeader.tsx index 6157f929ec04..1920bd750e18 100644 --- a/src/components/SelectionListWithSections/SortableTableHeader.tsx +++ b/src/components/SelectionListWithSections/SortableTableHeader.tsx @@ -26,6 +26,7 @@ type SearchTableHeaderProps = { shouldShowSorting: boolean; dateColumnSize: TableColumnSize; submittedColumnSize?: TableColumnSize; + approvedColumnSize?: TableColumnSize; amountColumnSize: TableColumnSize; taxAmountColumnSize: TableColumnSize; containerStyles?: StyleProp; @@ -41,6 +42,7 @@ function SortableTableHeader({ shouldShowColumn, dateColumnSize, submittedColumnSize, + approvedColumnSize, containerStyles, shouldShowSorting, onSortPress, @@ -80,6 +82,7 @@ function SortableTableHeader({ taxAmountColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE, !!areAllOptionalColumnsHidden, submittedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE, + approvedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE, ), ]} isSortable={isSortable} diff --git a/src/components/SelectionListWithSections/types.ts b/src/components/SelectionListWithSections/types.ts index cc5f8bd7c864..f577aba755c8 100644 --- a/src/components/SelectionListWithSections/types.ts +++ b/src/components/SelectionListWithSections/types.ts @@ -246,6 +246,9 @@ type TransactionListItemType = ListItem & /** The date the report was submitted */ submitted?: string; + /** The date the report was approved */ + approved?: string; + /** Policy to which the transaction belongs */ policy: Policy | undefined; @@ -289,6 +292,11 @@ type TransactionListItemType = ListItem & */ shouldShowYearSubmitted: boolean; + /** Whether we should show the year for the approved date. + * This is true if at least one transaction in the dataset was approved in past years + */ + shouldShowYearApproved: boolean; + isAmountColumnWide: boolean; isTaxAmountColumnWide: boolean; @@ -413,6 +421,12 @@ type TransactionReportGroupListItemType = TransactionGroupListItemType & {groupe */ shouldShowYearSubmitted: boolean; + /** + * Whether we should show the year for the approved date. + * This is true if at least one report in the dataset was approved in past years + */ + shouldShowYearApproved: boolean; + /** The main action that can be performed for the report */ action: SearchTransactionAction | undefined; diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index c4eca3b0eac2..e16e7cc695f2 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -136,6 +136,7 @@ function TransactionItemRow({ shouldShowTooltip, dateColumnSize, submittedColumnSize, + approvedColumnSize, amountColumnSize, taxAmountColumnSize, onCheckboxPress = () => {}, @@ -168,6 +169,7 @@ function TransactionItemRow({ const isDateColumnWide = dateColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE; const isSubmittedColumnWide = submittedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE; + const isApprovedColumnWide = approvedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE; const isAmountColumnWide = amountColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE; const isTaxAmountColumnWide = taxAmountColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE; @@ -262,7 +264,7 @@ function TransactionItemRow({ [CONST.REPORT.TRANSACTION_LIST.COLUMNS.SUBMITTED]: ( ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.APPROVED]: ( + + + + ), [CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY]: ( Date: Mon, 15 Dec 2025 14:38:43 -0700 Subject: [PATCH 4/8] update searchuiutils --- src/libs/SearchUIUtils.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 634572fbd41c..7da91af3c83f 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -137,6 +137,7 @@ const transactionColumnNamesToSortingProperty: TransactionSorting = { [CONST.SEARCH.TABLE_COLUMNS.FROM]: 'formattedFrom' as const, [CONST.SEARCH.TABLE_COLUMNS.DATE]: 'date' as const, [CONST.SEARCH.TABLE_COLUMNS.SUBMITTED]: 'submitted' as const, + [CONST.SEARCH.TABLE_COLUMNS.APPROVED]: 'approved' as const, [CONST.SEARCH.TABLE_COLUMNS.TAG]: 'tag' as const, [CONST.SEARCH.TABLE_COLUMNS.MERCHANT]: 'formattedMerchant' as const, [CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: 'formattedTotal' as const, @@ -161,6 +162,7 @@ const expenseReportColumnNamesToSortingProperty: ExpenseReportSorting = { [CONST.SEARCH.TABLE_COLUMNS.AVATAR]: null, [CONST.SEARCH.TABLE_COLUMNS.DATE]: 'created' as const, [CONST.SEARCH.TABLE_COLUMNS.SUBMITTED]: 'submitted' as const, + [CONST.SEARCH.TABLE_COLUMNS.APPROVED]: 'approved' as const, [CONST.SEARCH.TABLE_COLUMNS.STATUS]: 'formattedStatus' as const, [CONST.SEARCH.TABLE_COLUMNS.TITLE]: 'reportName' as const, [CONST.SEARCH.TABLE_COLUMNS.FROM]: 'formattedFrom' as const, @@ -645,7 +647,7 @@ function getTransactionItemCommonFormattedProperties( policy: OnyxTypes.Policy, formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], report: OnyxTypes.Report | undefined, -): Pick { +): Pick { const isExpenseReport = report?.type === CONST.REPORT.TYPE.EXPENSE; const fromName = getDisplayNameOrDefault(from); @@ -664,12 +666,14 @@ function getTransactionItemCommonFormattedProperties( const merchant = getTransactionMerchant(transactionItem, policy); const formattedMerchant = merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? '' : merchant; const submitted = report?.submitted; + const approved = report?.approved; return { formattedFrom, formattedTo, date, submitted, + approved, formattedTotal, formattedMerchant, }; @@ -1105,7 +1109,7 @@ function getTransactionsSections( isActionLoadingSet: ReadonlySet | undefined, ): [TransactionListItemType[], number] { const shouldShowMerchant = getShouldShowMerchant(data); - const {shouldShowYearCreated, shouldShowYearSubmitted} = shouldShowYear(data); + const {shouldShowYearCreated, shouldShowYearSubmitted, shouldShowYearApproved} = shouldShowYear(data); const {shouldShowAmountInWideColumn, shouldShowTaxAmountInWideColumn} = getWideAmountIndicators(data); // Pre-filter transaction keys to avoid repeated checks @@ -1154,7 +1158,7 @@ function getTransactionsSections( const from = reportAction?.actorAccountID ? (personalDetailsMap.get(reportAction.actorAccountID.toString()) ?? emptyPersonalDetails) : emptyPersonalDetails; const to = getToFieldValueForTransaction(transactionItem, report, data.personalDetailsList, reportAction); - const {formattedFrom, formattedTo, formattedTotal, formattedMerchant, date, submitted} = getTransactionItemCommonFormattedProperties( + const {formattedFrom, formattedTo, formattedTotal, formattedMerchant, date, submitted, approved} = getTransactionItemCommonFormattedProperties( transactionItem, from, to, @@ -1180,9 +1184,11 @@ function getTransactionsSections( formattedMerchant, date, submitted, + approved, shouldShowMerchant, shouldShowYear: shouldShowYearCreated, shouldShowYearSubmitted, + shouldShowYearApproved, isAmountColumnWide: shouldShowAmountInWideColumn, isTaxAmountColumnWide: shouldShowTaxAmountInWideColumn, violations: transactionViolations, @@ -1554,7 +1560,7 @@ function getReportSections( ): [TransactionGroupListItemType[], number] { const shouldShowMerchant = getShouldShowMerchant(data); - const {shouldShowYearCreated: shouldShowYearCreatedTransaction, shouldShowYearSubmitted: shouldShowYearSubmittedTransaction} = shouldShowYear(data); + const {shouldShowYearCreated: shouldShowYearCreatedTransaction, shouldShowYearSubmitted: shouldShowYearSubmittedTransaction, shouldShowYearApproved: shouldShowYearApprovedTransaction} = shouldShowYear(data); const {shouldShowAmountInWideColumn, shouldShowTaxAmountInWideColumn} = getWideAmountIndicators(data); const {moneyRequestReportActionsByTransactionID, holdReportActionsByTransactionID} = createReportActionsLookupMaps(data); @@ -1577,7 +1583,7 @@ function getReportSections( ); const orderedKeys: string[] = [...reportKeys, ...transactionKeys]; - const {shouldShowYearCreated: shouldShowYearCreatedReport, shouldShowYearSubmitted: shouldShowYearSubmittedReport} = shouldShowYear(data, true); + const {shouldShowYearCreated: shouldShowYearCreatedReport, shouldShowYearSubmitted: shouldShowYearSubmittedReport, shouldShowYearApproved: shouldShowYearApprovedReport} = shouldShowYear(data, true); for (const key of orderedKeys) { if (isReportEntry(key) && (data[key].type === CONST.REPORT.TYPE.IOU || data[key].type === CONST.REPORT.TYPE.EXPENSE || data[key].type === CONST.REPORT.TYPE.INVOICE)) { @@ -1652,6 +1658,7 @@ function getReportSections( ...(reportPendingAction ? {pendingAction: reportPendingAction} : {}), shouldShowYear: shouldShowYearCreatedReport, shouldShowYearSubmitted: shouldShowYearSubmittedReport, + shouldShowYearApproved: shouldShowYearApprovedReport, hasVisibleViolations: hasVisibleViolationsForReport, }; @@ -1699,6 +1706,7 @@ function getReportSections( shouldShowMerchant, shouldShowYear: shouldShowYearCreatedTransaction, shouldShowYearSubmitted: shouldShowYearSubmittedTransaction, + shouldShowYearApproved: shouldShowYearApprovedTransaction, keyForList: transactionItem.transactionID, violations: transactionViolations, isAmountColumnWide: shouldShowAmountInWideColumn, @@ -2495,6 +2503,7 @@ function getColumnsToShow( [CONST.SEARCH.TABLE_COLUMNS.AVATAR]: true, [CONST.SEARCH.TABLE_COLUMNS.DATE]: true, [CONST.SEARCH.TABLE_COLUMNS.SUBMITTED]: true, + [CONST.SEARCH.TABLE_COLUMNS.APPROVED]: true, [CONST.SEARCH.TABLE_COLUMNS.STATUS]: true, [CONST.SEARCH.TABLE_COLUMNS.TITLE]: true, [CONST.SEARCH.TABLE_COLUMNS.FROM]: true, @@ -2544,6 +2553,7 @@ function getColumnsToShow( [CONST.SEARCH.TABLE_COLUMNS.TYPE]: true, [CONST.SEARCH.TABLE_COLUMNS.DATE]: true, [CONST.SEARCH.TABLE_COLUMNS.SUBMITTED]: true, + [CONST.SEARCH.TABLE_COLUMNS.APPROVED]: true, [CONST.SEARCH.TABLE_COLUMNS.MERCHANT]: false, [CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION]: false, [CONST.SEARCH.TABLE_COLUMNS.FROM]: false, @@ -2740,7 +2750,7 @@ function getTableMinWidth(columns: SearchColumnType[]) { minWidth += 80; } else if (column === CONST.SEARCH.TABLE_COLUMNS.DATE) { minWidth += 48; - } else if (column === CONST.SEARCH.TABLE_COLUMNS.SUBMITTED) { + } else if (column === CONST.SEARCH.TABLE_COLUMNS.SUBMITTED || column === CONST.SEARCH.TABLE_COLUMNS.APPROVED) { minWidth += 72; } else if (column === CONST.SEARCH.TABLE_COLUMNS.TYPE) { minWidth += 20; From 81497cabaed644e6099dcfa6661b88f255684b8c Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 15 Dec 2025 14:40:07 -0700 Subject: [PATCH 5/8] add to report keys --- src/styles/utils/index.ts | 4 ++++ src/types/onyx/Report.ts | 3 +++ src/types/utils/whitelistedReportKeys.ts | 1 + 3 files changed, 8 insertions(+) diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index 1d62b86ace97..743a0af610d1 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -1725,6 +1725,7 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ isTaxAmountColumnWide = false, isDateColumnFullWidth = false, isSubmittedColumnWide = false, + isApprovedColumnWide = false, ): ViewStyle => { let columnWidth; switch (columnName) { @@ -1741,6 +1742,9 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ case CONST.SEARCH.TABLE_COLUMNS.SUBMITTED: columnWidth = {...getWidthStyle(isSubmittedColumnWide ? variables.w92 : variables.w72)}; break; + case CONST.SEARCH.TABLE_COLUMNS.APPROVED: + columnWidth = {...getWidthStyle(isApprovedColumnWide ? variables.w92 : variables.w72)}; + break; case CONST.SEARCH.TABLE_COLUMNS.DATE: if (isDateColumnFullWidth) { columnWidth = styles.flex1; diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 5e2fca054ae2..e24850da1638 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -92,6 +92,9 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** The date the report was submitted */ submitted?: string; + /** The date the report was approved */ + approved?: string; + /** The specific type of chat */ chatType?: ValueOf; diff --git a/src/types/utils/whitelistedReportKeys.ts b/src/types/utils/whitelistedReportKeys.ts index c3f10b4da0e2..873b144c0979 100644 --- a/src/types/utils/whitelistedReportKeys.ts +++ b/src/types/utils/whitelistedReportKeys.ts @@ -33,6 +33,7 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback< type: unknown; created: unknown; submitted: unknown; + approved: unknown; visibility: unknown; invoiceReceiver: unknown; parentReportID: unknown; From 974ea106cda6e67ed30c7e44b5727ee9cd5db792 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 15 Dec 2025 14:49:06 -0700 Subject: [PATCH 6/8] update tests --- .../Search/TransactionListItem.tsx | 8 ++++++- src/libs/SearchUIUtils.ts | 12 ++++++++-- tests/unit/MoneyRequestReportUtilsTest.ts | 3 +++ tests/unit/Search/SearchUIUtilsTest.ts | 24 +++++++++++++++++-- .../Search/handleActionButtonPressTest.ts | 6 +++++ tests/unit/TransactionGroupListItemTest.tsx | 4 ++++ 6 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/components/SelectionListWithSections/Search/TransactionListItem.tsx b/src/components/SelectionListWithSections/Search/TransactionListItem.tsx index 736d146f1115..ace8ad6f66ff 100644 --- a/src/components/SelectionListWithSections/Search/TransactionListItem.tsx +++ b/src/components/SelectionListWithSections/Search/TransactionListItem.tsx @@ -106,7 +106,13 @@ function TransactionListItem({ submittedColumnSize: transactionItem.shouldShowYearSubmitted ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL, approvedColumnSize: transactionItem.shouldShowYearApproved ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL, }; - }, [transactionItem.isAmountColumnWide, transactionItem.isTaxAmountColumnWide, transactionItem.shouldShowYear, transactionItem.shouldShowYearSubmitted, transactionItem.shouldShowYearApproved]); + }, [ + transactionItem.isAmountColumnWide, + transactionItem.isTaxAmountColumnWide, + transactionItem.shouldShowYear, + transactionItem.shouldShowYearSubmitted, + transactionItem.shouldShowYearApproved, + ]); const transactionViolations = useMemo(() => { return (violations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionItem.transactionID}`] ?? []).filter( diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 7da91af3c83f..b9a45082738f 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -1560,7 +1560,11 @@ function getReportSections( ): [TransactionGroupListItemType[], number] { const shouldShowMerchant = getShouldShowMerchant(data); - const {shouldShowYearCreated: shouldShowYearCreatedTransaction, shouldShowYearSubmitted: shouldShowYearSubmittedTransaction, shouldShowYearApproved: shouldShowYearApprovedTransaction} = shouldShowYear(data); + const { + shouldShowYearCreated: shouldShowYearCreatedTransaction, + shouldShowYearSubmitted: shouldShowYearSubmittedTransaction, + shouldShowYearApproved: shouldShowYearApprovedTransaction, + } = shouldShowYear(data); const {shouldShowAmountInWideColumn, shouldShowTaxAmountInWideColumn} = getWideAmountIndicators(data); const {moneyRequestReportActionsByTransactionID, holdReportActionsByTransactionID} = createReportActionsLookupMaps(data); @@ -1583,7 +1587,11 @@ function getReportSections( ); const orderedKeys: string[] = [...reportKeys, ...transactionKeys]; - const {shouldShowYearCreated: shouldShowYearCreatedReport, shouldShowYearSubmitted: shouldShowYearSubmittedReport, shouldShowYearApproved: shouldShowYearApprovedReport} = shouldShowYear(data, true); + const { + shouldShowYearCreated: shouldShowYearCreatedReport, + shouldShowYearSubmitted: shouldShowYearSubmittedReport, + shouldShowYearApproved: shouldShowYearApprovedReport, + } = shouldShowYear(data, true); for (const key of orderedKeys) { if (isReportEntry(key) && (data[key].type === CONST.REPORT.TYPE.IOU || data[key].type === CONST.REPORT.TYPE.EXPENSE || data[key].type === CONST.REPORT.TYPE.INVOICE)) { diff --git a/tests/unit/MoneyRequestReportUtilsTest.ts b/tests/unit/MoneyRequestReportUtilsTest.ts index 616603708fea..7c9780747afe 100644 --- a/tests/unit/MoneyRequestReportUtilsTest.ts +++ b/tests/unit/MoneyRequestReportUtilsTest.ts @@ -17,6 +17,7 @@ const reportBaseMock: Report = { chatReportID: '1706144653204915', created: '2024-12-21 13:05:20', submitted: '2024-12-21 13:05:20', + approved: undefined, currency: 'USD', isWaitingOnBankAccount: false, managerID: 100, @@ -62,6 +63,7 @@ const transactionItemBaseMock: TransactionListItemType = { comment: {comment: ''}, created: '2024-12-21', submitted: '2024-12-21', + approved: undefined, currency: 'USD', date: '2024-12-21', formattedFrom: 'Admin', @@ -87,6 +89,7 @@ const transactionItemBaseMock: TransactionListItemType = { shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, isAmountColumnWide: false, isTaxAmountColumnWide: false, tag: '', diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index c706c1f49d0f..03f4015a36da 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -111,6 +111,7 @@ const report2 = { chatReportID: '1706144653204915', created: '2024-12-21 13:05:20', submitted: '2024-12-21 13:05:20', + approved: undefined, currency: 'USD', isOneTransactionReport: true, isWaitingOnBankAccount: false, @@ -134,6 +135,7 @@ const report3 = { chatType: undefined, created: '2025-03-05 16:34:27', submitted: '2025-03-05', + approved: undefined, currency: 'VND', isOneTransactionReport: false, isOwnPolicyExpenseChat: false, @@ -767,6 +769,7 @@ const transactionsListItems = [ comment: {comment: ''}, created: '2024-12-21', submitted: undefined, + approved: undefined, currency: 'USD', date: '2024-12-21', formattedFrom: 'Admin', @@ -792,6 +795,7 @@ const transactionsListItems = [ shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, isAmountColumnWide: false, isTaxAmountColumnWide: false, tag: '', @@ -820,6 +824,7 @@ const transactionsListItems = [ comment: {comment: ''}, created: '2024-12-21', submitted: '2024-12-21 13:05:20', + approved: undefined, currency: 'USD', date: '2024-12-21', formattedFrom: 'Admin', @@ -844,6 +849,7 @@ const transactionsListItems = [ shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, isAmountColumnWide: false, isTaxAmountColumnWide: false, tag: '', @@ -883,6 +889,7 @@ const transactionsListItems = [ comment: {comment: ''}, created: '2025-03-05', submitted: '2025-03-05', + approved: undefined, currency: 'VND', hasEReceipt: false, merchant: '(none)', @@ -914,6 +921,7 @@ const transactionsListItems = [ shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, keyForList: '3', isAmountColumnWide: false, isTaxAmountColumnWide: false, @@ -941,6 +949,7 @@ const transactionsListItems = [ comment: {comment: ''}, created: '2025-03-05', submitted: '2025-03-05', + approved: undefined, currency: 'VND', hasEReceipt: false, merchant: '(none)', @@ -972,6 +981,7 @@ const transactionsListItems = [ shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, keyForList: '4', isAmountColumnWide: false, isTaxAmountColumnWide: false, @@ -1017,6 +1027,7 @@ const transactionReportGroupListItems = [ reportName: 'Expense Report #123', shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, stateNum: 0, statusNum: 0, to: emptyPersonalDetails, @@ -1061,6 +1072,7 @@ const transactionReportGroupListItems = [ shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, isAmountColumnWide: false, isTaxAmountColumnWide: false, tag: '', @@ -1087,6 +1099,7 @@ const transactionReportGroupListItems = [ chatReportID: '1706144653204915', created: '2024-12-21 13:05:20', submitted: '2024-12-21 13:05:20', + approved: undefined, currency: 'USD', formattedFrom: 'Admin', formattedStatus: 'Outstanding', @@ -1109,6 +1122,7 @@ const transactionReportGroupListItems = [ reportName: 'Expense Report #123', shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, stateNum: 1, statusNum: 1, to: { @@ -1163,6 +1177,7 @@ const transactionReportGroupListItems = [ shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, isAmountColumnWide: false, isTaxAmountColumnWide: false, tag: '', @@ -1193,6 +1208,7 @@ const transactionReportGroupListItems = [ chatType: undefined, created: '2025-03-05 16:34:27', submitted: '2025-03-05', + approved: undefined, currency: 'VND', formattedFrom: 'Admin', formattedStatus: 'Outstanding', @@ -1211,6 +1227,7 @@ const transactionReportGroupListItems = [ reportName: 'Approver owes ₫44.00', shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, stateNum: 1, statusNum: 1, total: 4400, @@ -1277,6 +1294,7 @@ const transactionReportGroupListItems = [ shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, keyForList: '3', isAmountColumnWide: false, isTaxAmountColumnWide: false, @@ -1334,6 +1352,7 @@ const transactionReportGroupListItems = [ shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, keyForList: '4', isAmountColumnWide: false, isTaxAmountColumnWide: false, @@ -1378,6 +1397,7 @@ const transactionReportGroupListItems = [ reportName: 'Expense Report #123', shouldShowYear: true, shouldShowYearSubmitted: true, + shouldShowYearApproved: false, stateNum: 0, statusNum: 0, to: emptyPersonalDetails, @@ -1829,7 +1849,7 @@ describe('SearchUIUtils', () => { expect(distanceTransaction).toBeDefined(); expect(distanceTransaction?.iouRequestType).toBe(CONST.IOU.REQUEST_TYPE.DISTANCE); - const expectedPropertyCount = 47; + const expectedPropertyCount = 49; expect(Object.keys(distanceTransaction ?? {}).length).toBe(expectedPropertyCount); }); @@ -1862,7 +1882,7 @@ describe('SearchUIUtils', () => { expect(distanceTransaction).toBeDefined(); expect(distanceTransaction?.iouRequestType).toBe(CONST.IOU.REQUEST_TYPE.DISTANCE); - const expectedPropertyCount = 46; + const expectedPropertyCount = 47; expect(Object.keys(distanceTransaction ?? {}).length).toBe(expectedPropertyCount); }); diff --git a/tests/unit/Search/handleActionButtonPressTest.ts b/tests/unit/Search/handleActionButtonPressTest.ts index 6adf6279af0b..39e62e3ee2f7 100644 --- a/tests/unit/Search/handleActionButtonPressTest.ts +++ b/tests/unit/Search/handleActionButtonPressTest.ts @@ -17,6 +17,7 @@ const mockReportItemWithHold = { chatReportID: '2108006919825366', created: '2024-12-04 23:18:33', submitted: '2024-12-04', + approved: undefined, currency: 'USD', isOneTransactionReport: false, isPolicyExpenseChat: false, @@ -66,6 +67,7 @@ const mockReportItemWithHold = { }, shouldShowYear: false, shouldShowYearSubmitted: false, + shouldShowYearApproved: false, transactions: [ { report: { @@ -110,6 +112,7 @@ const mockReportItemWithHold = { modifiedMerchant: '', parentTransactionID: '', submitted: '2024-12-04', + approved: undefined, policyID: '48D7178DE42EE9F9', reportID: '1350959062018695', reportType: 'expense', @@ -154,6 +157,7 @@ const mockReportItemWithHold = { shouldShowMerchant: true, shouldShowYear: false, shouldShowYearSubmitted: false, + shouldShowYearApproved: false, keyForList: '1049531721038862176', isAmountColumnWide: false, isTaxAmountColumnWide: false, @@ -190,6 +194,7 @@ const mockReportItemWithHold = { }, created: '2024-12-04', submitted: '2024-12-04', + approved: undefined, currency: 'USD', hasEReceipt: false, merchant: 'Forbes', @@ -221,6 +226,7 @@ const mockReportItemWithHold = { shouldShowMerchant: true, shouldShowYear: false, shouldShowYearSubmitted: false, + shouldShowYearApproved: false, keyForList: '5345995386715609966', isAmountColumnWide: false, isTaxAmountColumnWide: false, diff --git a/tests/unit/TransactionGroupListItemTest.tsx b/tests/unit/TransactionGroupListItemTest.tsx index 6e951836b48b..9017036ffdc9 100644 --- a/tests/unit/TransactionGroupListItemTest.tsx +++ b/tests/unit/TransactionGroupListItemTest.tsx @@ -31,6 +31,7 @@ const mockTransaction: TransactionListItemType = { groupCurrency: 'USD', created: '2025-09-19', submitted: '2025-09-19', + approved: undefined, currency: 'USD', policy: { id: '06F34677820A4D07', @@ -66,6 +67,7 @@ const mockTransaction: TransactionListItemType = { shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: false, + shouldShowYearApproved: false, keyForList: '1', isAmountColumnWide: false, isTaxAmountColumnWide: false, @@ -91,6 +93,7 @@ const mockReport: TransactionReportGroupListItemType = { chatType: undefined, created: '2025-09-19 20:00:47', submitted: '2025-09-19', + approved: undefined, currency: 'USD', isOneTransactionReport: true, isOwnPolicyExpenseChat: false, @@ -121,6 +124,7 @@ const mockReport: TransactionReportGroupListItemType = { }, shouldShowYear: false, shouldShowYearSubmitted: false, + shouldShowYearApproved: false, action: 'view', transactions: [], groupedBy: 'expense-report', From 3088ce194149ad08ec51461ebdd1777d75a920a3 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 15 Dec 2025 14:56:56 -0700 Subject: [PATCH 7/8] fix ts --- 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 e16e7cc695f2..06a1e98c4cfe 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -93,6 +93,7 @@ type TransactionItemRowProps = { shouldShowTooltip: boolean; dateColumnSize: TableColumnSize; submittedColumnSize?: TableColumnSize; + approvedColumnSize?: TableColumnSize; amountColumnSize: TableColumnSize; taxAmountColumnSize: TableColumnSize; onCheckboxPress?: (transactionID: string) => void; From b1203aa267cdd24bf553b9ecfe2c87d3b342da10 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 15 Dec 2025 19:03:26 -0700 Subject: [PATCH 8/8] update tests --- tests/unit/Search/SearchUIUtilsTest.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index a9603ec5d6ee..4fa3815849c0 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -2724,6 +2724,7 @@ describe('SearchUIUtils', () => { [CONST.SEARCH.TABLE_COLUMNS.AVATAR]: true, [CONST.SEARCH.TABLE_COLUMNS.DATE]: true, [CONST.SEARCH.TABLE_COLUMNS.SUBMITTED]: false, + [CONST.SEARCH.TABLE_COLUMNS.APPROVED]: false, [CONST.SEARCH.TABLE_COLUMNS.STATUS]: true, [CONST.SEARCH.TABLE_COLUMNS.TITLE]: true, [CONST.SEARCH.TABLE_COLUMNS.FROM]: true, @@ -2741,6 +2742,7 @@ describe('SearchUIUtils', () => { [CONST.SEARCH.TABLE_COLUMNS.AVATAR]: true, [CONST.SEARCH.TABLE_COLUMNS.DATE]: true, [CONST.SEARCH.TABLE_COLUMNS.SUBMITTED]: false, + [CONST.SEARCH.TABLE_COLUMNS.APPROVED]: false, [CONST.SEARCH.TABLE_COLUMNS.STATUS]: true, [CONST.SEARCH.TABLE_COLUMNS.TITLE]: true, [CONST.SEARCH.TABLE_COLUMNS.FROM]: false,