diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 75bdd48c2894..98f06ea33b38 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -6688,6 +6688,7 @@ const CONST = { RECEIPT: this.TABLE_COLUMNS.RECEIPT, DATE: this.TABLE_COLUMNS.DATE, SUBMITTED: this.TABLE_COLUMNS.SUBMITTED, + APPROVED: this.TABLE_COLUMNS.APPROVED, MERCHANT: this.TABLE_COLUMNS.MERCHANT, FROM: this.TABLE_COLUMNS.FROM, TO: this.TABLE_COLUMNS.TO, @@ -6698,6 +6699,7 @@ const CONST = { EXPENSE_REPORT: { DATE: this.TABLE_COLUMNS.DATE, SUBMITTED: this.TABLE_COLUMNS.SUBMITTED, + APPROVED: this.TABLE_COLUMNS.APPROVED, STATUS: this.TABLE_COLUMNS.STATUS, TITLE: this.TABLE_COLUMNS.TITLE, FROM: this.TABLE_COLUMNS.FROM, @@ -6776,6 +6778,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 fda71d655181..7df17422c8d3 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -1037,7 +1037,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; @@ -1069,6 +1069,7 @@ function Search({ sortBy={sortBy} shouldShowYear={shouldShowYearCreated} shouldShowYearSubmitted={shouldShowYearSubmitted} + shouldShowYearApproved={shouldShowYearApproved} isAmountColumnWide={shouldShowAmountInWideColumn} isTaxAmountColumnWide={shouldShowTaxAmountInWideColumn} shouldShowSorting={shouldShowSorting} diff --git a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx index 558671578da9..0eb845a3401b 100644 --- a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx +++ b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx @@ -97,6 +97,15 @@ function ExpenseReportListItemRow({ /> ), + [CONST.SEARCH.TABLE_COLUMNS.APPROVED]: ( + + + + ), [CONST.SEARCH.TABLE_COLUMNS.STATUS]: ( ({ 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( @@ -185,6 +192,7 @@ function TransactionListItem({ isSelected={!!transactionItem.isSelected} dateColumnSize={dateColumnSize} submittedColumnSize={submittedColumnSize} + approvedColumnSize={approvedColumnSize} amountColumnSize={amountColumnSize} taxAmountColumnSize={taxAmountColumnSize} shouldShowCheckbox={!!canSelectMultiple} diff --git a/src/components/SelectionListWithSections/SearchTableHeader.tsx b/src/components/SelectionListWithSections/SearchTableHeader.tsx index 8ab5da2c19a3..5e988d208aad 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 61c3af8db33d..9db2323fbd90 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 bd06a2d3f912..000cfd4d0f85 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -90,6 +90,7 @@ type TransactionItemRowProps = { shouldShowTooltip: boolean; dateColumnSize: TableColumnSize; submittedColumnSize?: TableColumnSize; + approvedColumnSize?: TableColumnSize; amountColumnSize: TableColumnSize; taxAmountColumnSize: TableColumnSize; onCheckboxPress?: (transactionID: string) => void; @@ -133,6 +134,7 @@ function TransactionItemRow({ shouldShowTooltip, dateColumnSize, submittedColumnSize, + approvedColumnSize, amountColumnSize, taxAmountColumnSize, onCheckboxPress = () => {}, @@ -165,6 +167,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; @@ -268,6 +271,18 @@ function TransactionItemRow({ /> ), + [CONST.SEARCH.TABLE_COLUMNS.APPROVED]: ( + + + + ), [CONST.SEARCH.TABLE_COLUMNS.CATEGORY]: ( { +): Pick { const isExpenseReport = report?.type === CONST.REPORT.TYPE.EXPENSE; const fromName = getDisplayNameOrDefault(from); @@ -666,12 +668,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, }; @@ -853,6 +857,7 @@ function getWideAmountIndicators(data: TransactionListItemType[] | TransactionGr type ShouldShowYearResult = { shouldShowYearCreated: boolean; shouldShowYearSubmitted: boolean; + shouldShowYearApproved: boolean; }; /** @@ -868,6 +873,7 @@ function shouldShowYear( const result: ShouldShowYearResult = { shouldShowYearCreated: false, shouldShowYearSubmitted: false, + shouldShowYearApproved: false, }; const currentYear = new Date().getFullYear(); @@ -887,6 +893,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); @@ -896,6 +905,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 @@ -916,6 +928,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)) { @@ -933,6 +948,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 @@ -1093,7 +1111,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 @@ -1142,7 +1160,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, @@ -1168,9 +1186,11 @@ function getTransactionsSections( formattedMerchant, date, submitted, + approved, shouldShowMerchant, shouldShowYear: shouldShowYearCreated, shouldShowYearSubmitted, + shouldShowYearApproved, isAmountColumnWide: shouldShowAmountInWideColumn, isTaxAmountColumnWide: shouldShowTaxAmountInWideColumn, violations: transactionViolations, @@ -1542,7 +1562,11 @@ 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); @@ -1565,7 +1589,11 @@ 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)) { @@ -1640,6 +1668,7 @@ function getReportSections( ...(reportPendingAction ? {pendingAction: reportPendingAction} : {}), shouldShowYear: shouldShowYearCreatedReport, shouldShowYearSubmitted: shouldShowYearSubmittedReport, + shouldShowYearApproved: shouldShowYearApprovedReport, hasVisibleViolations: hasVisibleViolationsForReport, }; @@ -1687,6 +1716,7 @@ function getReportSections( shouldShowMerchant, shouldShowYear: shouldShowYearCreatedTransaction, shouldShowYearSubmitted: shouldShowYearSubmittedTransaction, + shouldShowYearApproved: shouldShowYearApprovedTransaction, keyForList: transactionItem.transactionID, violations: transactionViolations, isAmountColumnWide: shouldShowAmountInWideColumn, @@ -2149,6 +2179,8 @@ function getSearchColumnTranslationKey(columnId: SearchCustomColumnIds): Transla return 'common.date'; case CONST.SEARCH.TABLE_COLUMNS.SUBMITTED: return 'common.submitted'; + case CONST.SEARCH.TABLE_COLUMNS.APPROVED: + return 'search.filters.approved'; case CONST.SEARCH.TABLE_COLUMNS.MERCHANT: return 'common.merchant'; case CONST.SEARCH.TABLE_COLUMNS.FROM: @@ -2548,6 +2580,7 @@ function getColumnsToShow( [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, @@ -2617,6 +2650,7 @@ function getColumnsToShow( [CONST.SEARCH.TABLE_COLUMNS.TYPE]: true, [CONST.SEARCH.TABLE_COLUMNS.DATE]: true, [CONST.SEARCH.TABLE_COLUMNS.SUBMITTED]: false, + [CONST.SEARCH.TABLE_COLUMNS.APPROVED]: false, [CONST.SEARCH.TABLE_COLUMNS.MERCHANT]: false, [CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION]: false, [CONST.SEARCH.TABLE_COLUMNS.FROM]: false, @@ -2826,7 +2860,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; diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index a82d65ac4835..be6adc1f30db 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: // We will remove this variable & param, but in a follow up PR. We are duplicating the logic here to "use" the variable // to prevent eslint errors. This will be removed 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; 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 fd11d68d88f3..a74629224e10 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); }); @@ -2704,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, @@ -2721,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, 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',