diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 6709d1864767..7a19cb8e1ac4 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -6700,6 +6700,9 @@ const CONST = { EXPORTED_TO: {column: this.TABLE_COLUMNS.EXPORTED_TO, search: true, reportView: false}, ACTION: {column: this.TABLE_COLUMNS.ACTION, search: true, reportView: false}, WITHDRAWAL_ID: {column: this.TABLE_COLUMNS.WITHDRAWAL_ID, search: true, reportView: true}, + SUBMITTER_USER_ID: {column: this.TABLE_COLUMNS.SUBMITTER_USER_ID, search: true, reportView: true}, + SUBMITTER_PAYROLL_ID: {column: this.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID, search: true, reportView: true}, + ORDER_DEAL_NUMBERS: {column: this.TABLE_COLUMNS.ORDER_DEAL_NUMBERS, search: true, reportView: true}, }; }, get TYPE_CUSTOM_COLUMNS() { @@ -6726,6 +6729,9 @@ const CONST = { REPORT_ID: this.TABLE_COLUMNS.REPORT_ID, BASE_62_REPORT_ID: this.TABLE_COLUMNS.BASE_62_REPORT_ID, AMOUNT: this.TABLE_COLUMNS.TOTAL, + SUBMITTER_USER_ID: this.TABLE_COLUMNS.SUBMITTER_USER_ID, + SUBMITTER_PAYROLL_ID: this.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID, + ORDER_DEAL_NUMBERS: this.TABLE_COLUMNS.ORDER_DEAL_NUMBERS, EXPORTED_ICON: this.TABLE_COLUMNS.EXPORTED_TO, ACTION: this.TABLE_COLUMNS.ACTION, }, @@ -6933,6 +6939,9 @@ const CONST = { TAX_CODE: 'taxCode', CATEGORY_GL_CODE: 'categoryGLCode', WITHDRAWAL_ID: 'withdrawalID', + SUBMITTER_USER_ID: 'submitterUserID', + SUBMITTER_PAYROLL_ID: 'submitterPayrollID', + ORDER_DEAL_NUMBERS: 'orderDealNumbers', AVATAR: 'avatar', STATUS: 'status', EXPENSES: 'expenses', diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index 8b035f29a8df..f7e8aa9a6fdb 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -400,6 +400,7 @@ function MoneyRequestReportTransactionList({ return getColumnsToShow({ currentAccountID: currentUserDetails?.accountID, data: transactions, + report, visibleColumns: (isExpenseReportViewFromIOUReport ? [] : (reportDetailsColumns ?? [])) as SearchCustomColumnIds[], isExpenseReportView: true, isExpenseReportViewFromIOUReport, @@ -417,7 +418,7 @@ function MoneyRequestReportTransactionList({ shouldShowBillableColumn, shouldShowCommentsColumn, reportDetailsColumns, - report?.currency, + report, isTaxEnabled, policyCategories, ]); diff --git a/src/components/Search/SearchList/ListItem/ExpenseReportListItemRow/ExpenseReportListItemRowWide.tsx b/src/components/Search/SearchList/ListItem/ExpenseReportListItemRow/ExpenseReportListItemRowWide.tsx index 0c311b640d47..1bef2d059d33 100644 --- a/src/components/Search/SearchList/ListItem/ExpenseReportListItemRow/ExpenseReportListItemRowWide.tsx +++ b/src/components/Search/SearchList/ListItem/ExpenseReportListItemRow/ExpenseReportListItemRowWide.tsx @@ -48,6 +48,9 @@ function ExpenseReportListItemRowWide({ const currency = item.currency ?? CONST.CURRENCY.USD; const {totalDisplaySpend = 0, nonReimbursableSpend = 0, reimbursableSpend = 0, isAllScanning: isScanning = false} = item; + const submitterUserID = item.submitterUserID; + const submitterPayrollID = item.submitterPayrollID; + const orderDealNumbers = item.orderDealNumbers; const columnComponents = { [CONST.SEARCH.TABLE_COLUMNS.AVATAR]: ( @@ -175,6 +178,21 @@ function ExpenseReportListItemRowWide({ /> ), + [CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID]: ( + + + + ), + [CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID]: ( + + + + ), + [CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS]: ( + + + + ), [CONST.SEARCH.TABLE_COLUMNS.REPORT_ID]: ( diff --git a/src/components/Search/SearchTableHeader.tsx b/src/components/Search/SearchTableHeader.tsx index 7ef7041cd59a..3a6651e3a1fc 100644 --- a/src/components/Search/SearchTableHeader.tsx +++ b/src/components/Search/SearchTableHeader.tsx @@ -146,6 +146,18 @@ const getExpenseHeaders = (groupBy?: SearchGroupBy): SearchColumnConfig[] => [ columnName: CONST.SEARCH.TABLE_COLUMNS.WITHDRAWAL_ID, translationKey: 'common.withdrawalID', }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID, + translationKey: 'workspace.common.customField1', + }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID, + translationKey: 'workspace.common.customField2', + }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS, + translationKey: 'common.internationalReimbursementIDs', + }, { columnName: CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT, translationKey: groupBy ? 'common.total' : 'iou.amount', @@ -272,6 +284,18 @@ const getExpenseReportHeaders = (profileIcon?: IconAsset): SearchColumnConfig[] columnName: CONST.SEARCH.TABLE_COLUMNS.TOTAL, translationKey: 'common.total', }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID, + translationKey: 'workspace.common.customField1', + }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID, + translationKey: 'workspace.common.customField2', + }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS, + translationKey: 'common.internationalReimbursementIDs', + }, { columnName: CONST.SEARCH.TABLE_COLUMNS.BASE_62_REPORT_ID, translationKey: 'common.reportID', diff --git a/src/components/TransactionItemRow/TransactionItemRowWide.tsx b/src/components/TransactionItemRow/TransactionItemRowWide.tsx index 3507989a14b1..23f57318b8bd 100644 --- a/src/components/TransactionItemRow/TransactionItemRowWide.tsx +++ b/src/components/TransactionItemRow/TransactionItemRowWide.tsx @@ -132,6 +132,10 @@ function TransactionItemRowWide({ const isExportedColumnWide = exportedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE; const isAmountColumnWide = amountColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE; const isTaxAmountColumnWide = taxAmountColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE; + const reportForCustomColumns = transactionItem.report ?? report; + const submitterUserID = reportForCustomColumns?.submitterUserID; + const submitterPayrollID = reportForCustomColumns?.submitterPayrollID; + const orderDealNumbers = reportForCustomColumns?.orderDealNumbers; const renderColumn = (column: SearchColumnType): React.ReactNode => { switch (column) { @@ -598,6 +602,33 @@ function TransactionItemRowWide({ ); + case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID: + return ( + + + + ); + case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID: + return ( + + + + ); + case CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS: + return ( + + + + ); default: return null; } diff --git a/src/languages/de.ts b/src/languages/de.ts index ce16d34f9218..9ce7cfaca6db 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -395,6 +395,7 @@ const translations: TranslationDeepObject = { reportID: 'Berichts-ID', longReportID: 'Langer Bericht-ID', withdrawalID: 'Auszahlungs-ID', + internationalReimbursementIDs: 'Internationale Erstattungs-IDs', withdrawalStatus: 'Auszahlungsstatus', bankAccounts: 'Bankkonten', chooseFile: 'Datei auswählen', diff --git a/src/languages/en.ts b/src/languages/en.ts index 069b3fe7f9dd..102a3fcdff4c 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -415,6 +415,7 @@ const translations = { reportID: 'Report ID', longReportID: 'Long Report ID', withdrawalID: 'Withdrawal ID', + internationalReimbursementIDs: 'International reimbursement IDs', withdrawalStatus: 'Withdrawal status', bankAccounts: 'Bank accounts', chooseFile: 'Choose file', diff --git a/src/languages/es.ts b/src/languages/es.ts index a2761a34d3c2..97501a37c5e2 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -446,6 +446,7 @@ const translations: TranslationDeepObject = { exchangeRate: 'Tipo de cambio', reimbursableTotal: 'Total reembolsable', nonReimbursableTotal: 'Total no reembolsable', + internationalReimbursementIDs: 'IDs de reembolso internacional', opensInNewTab: 'Se abre en una nueva pestaña', locked: 'Bloqueado', month: 'Monat', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 882c1506c566..a53b882abaa3 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -394,6 +394,7 @@ const translations: TranslationDeepObject = { reportID: 'ID de note de frais', longReportID: 'ID de note de frais longue', withdrawalID: 'ID de retrait', + internationalReimbursementIDs: 'ID de remboursement international', withdrawalStatus: 'Statut de retrait', bankAccounts: 'Comptes bancaires', chooseFile: 'Choisir un fichier', diff --git a/src/languages/it.ts b/src/languages/it.ts index 0c30f5ba9c5d..1f101b2f7545 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -395,6 +395,7 @@ const translations: TranslationDeepObject = { reportID: 'ID report', longReportID: 'ID report dettagliato', withdrawalID: 'ID prelievo', + internationalReimbursementIDs: 'ID di rimborso internazionale', withdrawalStatus: 'Stato del prelievo', bankAccounts: 'Conti bancari', chooseFile: 'Scegli file', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index e4144a7243b5..ecf2553b0037 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -394,6 +394,7 @@ const translations: TranslationDeepObject = { reportID: 'レポートID', longReportID: '長いレポートID', withdrawalID: '出金ID', + internationalReimbursementIDs: '国際払い戻しID', withdrawalStatus: '出金ステータス', bankAccounts: '銀行口座', chooseFile: 'ファイルを選択', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 5ea102f87135..0ef123047cf8 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -394,6 +394,7 @@ const translations: TranslationDeepObject = { reportID: 'Rapport-ID', longReportID: 'Lang rapport-ID', withdrawalID: 'Opname-ID', + internationalReimbursementIDs: 'Internationale terugbetalings-ID’s', withdrawalStatus: 'Opnamestatus', bankAccounts: 'Bankrekeningen', chooseFile: 'Bestand kiezen', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 7de0bdd24b9c..01ba05b8263b 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -394,6 +394,7 @@ const translations: TranslationDeepObject = { reportID: 'ID raportu', longReportID: 'Długi identyfikator raportu', withdrawalID: 'Identyfikator wypłaty', + internationalReimbursementIDs: 'Identyfikatory zwrotów międzynarodowych', withdrawalStatus: 'Status wypłaty', bankAccounts: 'Konta bankowe', chooseFile: 'Wybierz plik', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index df679cbfa33b..f051cd88164d 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -394,6 +394,7 @@ const translations: TranslationDeepObject = { reportID: 'ID do relatório', longReportID: 'ID de relatório longo', withdrawalID: 'ID do saque', + internationalReimbursementIDs: 'IDs de reembolso internacional', withdrawalStatus: 'Status do saque', bankAccounts: 'Contas bancárias', chooseFile: 'Escolher arquivo', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 0704569b1a32..2831b55f6916 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -394,6 +394,7 @@ const translations: TranslationDeepObject = { reportID: '报销单编号', longReportID: '长报表 ID', withdrawalID: '提现编号', + internationalReimbursementIDs: '国际报销 ID', withdrawalStatus: '提现状态', bankAccounts: '银行账户', chooseFile: '选择文件', diff --git a/src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts index 901c774b39bc..b38159668f1b 100644 --- a/src/libs/DebugUtils.ts +++ b/src/libs/DebugUtils.ts @@ -443,6 +443,9 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa case 'welcomeMessage': case 'origin': case 'originalID': + case 'submitterUserID': + case 'submitterPayrollID': + case 'orderDealNumbers': return validateString(value); case 'hasOutstandingChildRequest': case 'hasOutstandingChildTask': @@ -579,6 +582,9 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa type: CONST.RED_BRICK_ROAD_PENDING_ACTION, policyID: CONST.RED_BRICK_ROAD_PENDING_ACTION, reportID: CONST.RED_BRICK_ROAD_PENDING_ACTION, + submitterUserID: CONST.RED_BRICK_ROAD_PENDING_ACTION, + submitterPayrollID: CONST.RED_BRICK_ROAD_PENDING_ACTION, + orderDealNumbers: CONST.RED_BRICK_ROAD_PENDING_ACTION, avatarUrl: CONST.RED_BRICK_ROAD_PENDING_ACTION, chatType: CONST.RED_BRICK_ROAD_PENDING_ACTION, hasOutstandingChildRequest: CONST.RED_BRICK_ROAD_PENDING_ACTION, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 4ebc40469a97..e4f26ba0781f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -20,6 +20,7 @@ import * as defaultGroupAvatars from '@components/Icon/GroupDefaultAvatars'; import * as defaultWorkspaceAvatars from '@components/Icon/WorkspaceDefaultAvatars'; import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider'; import type {MoneyRequestAmountInputProps} from '@components/MoneyRequestAmountInput'; +import type {SearchColumnType} from '@components/Search/types'; import type {TransactionWithOptionalSearchFields} from '@components/TransactionItemRow/types'; import type PolicyData from '@hooks/usePolicyData/types'; import type {PolicyTagList} from '@pages/workspace/tags/types'; @@ -13061,10 +13062,26 @@ const sortableColumnNames = [ CONST.SEARCH.TABLE_COLUMNS.TAX_RATE, CONST.SEARCH.TABLE_COLUMNS.CARD, CONST.SEARCH.TABLE_COLUMNS.WITHDRAWAL_ID, + CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID, + CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID, + CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS, ] as const; type SortableColumnName = TupleToUnion; +function getReportCustomColumnValue(key: SearchColumnType, report: OnyxEntry): string | undefined { + switch (key) { + case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID: + return report?.submitterUserID; + case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID: + return report?.submitterPayrollID; + case CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS: + return report?.orderDealNumbers; + default: + return undefined; + } +} + /** * Type guard to check if a column name is sortable */ @@ -13076,7 +13093,13 @@ function isSortableColumnName(key: unknown): key is SortableColumnName { * Get the sortable value for a transaction based on the column type. * Used for sorting transactions in MoneyRequestReportTransactionList. */ -function getTransactionSortValue(transaction: Transaction, key: SortableColumnName, report: Report, policy: OnyxEntry, policyCategories?: PolicyCategories): string | number { +function getTransactionSortValue( + transaction: Transaction, + key: SortableColumnName, + report: Report, + policy: OnyxEntry, + policyCategories?: PolicyCategories, +): string | number | undefined { switch (key) { case CONST.SEARCH.TABLE_COLUMNS.DATE: return getTransactionCreated(transaction); @@ -13115,6 +13138,10 @@ function getTransactionSortValue(transaction: Transaction, key: SortableColumnNa return transaction.cardID ?? CONST.DEFAULT_NUMBER_ID; case CONST.SEARCH.TABLE_COLUMNS.WITHDRAWAL_ID: return transaction.withdrawalID ? transaction.withdrawalID : ''; + case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID: + case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID: + case CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS: + return getReportCustomColumnValue(key, report); default: return ''; } @@ -13516,6 +13543,7 @@ export { isReportOpenOrUnsubmitted, getIconsForExpenseReport, shouldBlockSubmitDueToPreventSelfApproval, + getReportCustomColumnValue, getTransactionSortValue, isSortableColumnName, getLinkedIOUTransaction, diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index e9be211e62f5..c45f256b5283 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -145,6 +145,7 @@ import { getMoneyRequestSpendBreakdown, getPersonalDetailsForAccountID, getPolicyName, + getReportCustomColumnValue, getReportOrDraftReport, getReportStatusTranslation, hasHeldExpenses, @@ -3857,6 +3858,14 @@ function getSortedTransactionData( }); } + if (sortBy === CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID || sortBy === CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID || sortBy === CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS) { + return data.sort((a, b) => { + const aValue = getReportCustomColumnValue(sortBy, a.report); + const bValue = getReportCustomColumnValue(sortBy, b.report); + return compareValues(aValue, bValue, sortOrder, sortBy, localeCompare); + }); + } + const sortingProperty = sortBy === CONST.SEARCH.SORT_BY_COLUMNS.CATEGORY_GL_CODE ? undefined : transactionColumnNamesToSortingProperty[sortBy]; if (sortBy === CONST.SEARCH.TABLE_COLUMNS.POLICY_NAME) { @@ -4081,6 +4090,14 @@ function getSortedReportData( }); } + if (sortBy === CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID || sortBy === CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID || sortBy === CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS) { + return data.sort((a, b) => { + const aValue = getReportCustomColumnValue(sortBy, a); + const bValue = getReportCustomColumnValue(sortBy, b); + return compareValues(aValue, bValue, sortOrder, sortBy, localeCompare); + }); + } + const sortingProperty = sortBy === CONST.SEARCH.SORT_BY_COLUMNS.CATEGORY_GL_CODE ? undefined : expenseReportColumnNamesToSortingProperty[sortBy]; if (!sortingProperty) { @@ -4344,6 +4361,12 @@ function getSearchColumnTranslationKey(column: SearchSortBy): TranslationPaths { return 'common.total'; case CONST.SEARCH.TABLE_COLUMNS.WITHDRAWAL_ID: return 'common.withdrawalID'; + case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID: + return 'workspace.common.customField1'; + case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID: + return 'workspace.common.customField2'; + case CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS: + return 'common.internationalReimbursementIDs'; case CONST.SEARCH.TABLE_COLUMNS.GROUP_WITHDRAWAL_ID: return 'common.withdrawalID'; case CONST.SEARCH.TABLE_COLUMNS.GROUP_MONTH: @@ -5520,6 +5543,7 @@ function getPolicyCategoriesForPolicyID(policyCategories: PolicyCategoriesLookup function getColumnsToShow({ currentAccountID, data, + report, visibleColumns = [], isExpenseReportView = false, type, @@ -5536,6 +5560,7 @@ function getColumnsToShow({ }: { currentAccountID: number | undefined; data: OnyxTypes.SearchResults['data'] | OnyxTypes.Transaction[]; + report?: OnyxEntry; visibleColumns?: SearchCustomColumnIds[]; isExpenseReportView?: boolean; type?: SearchDataTypes; @@ -5550,6 +5575,14 @@ function getColumnsToShow({ policyCategories?: PolicyCategoriesLookup; fallbackPolicyID?: string; }): SearchColumnType[] { + const reportCustomColumns = new Set([ + CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID, + CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID, + CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS, + ]); + + const hasReportCustomColumnValue = (column: SearchColumnType, reportToCheck: OnyxEntry): boolean => !!getReportCustomColumnValue(column, reportToCheck); + if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { const defaultReportColumns: SearchColumnType[] = [ CONST.SEARCH.TABLE_COLUMNS.AVATAR, @@ -5585,7 +5618,24 @@ function getColumnsToShow({ result.push(col); } - return result; + if (Array.isArray(data)) { + return result; + } + + return result.filter((column) => { + if (!reportCustomColumns.has(column)) { + return true; + } + + return Object.keys(data).some((key) => { + if (!isReportEntry(key)) { + return false; + } + + const reportToCheck = data[key]; + return reportToCheck?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && hasReportCustomColumnValue(column, reportToCheck); + }); + }); } if (type === CONST.SEARCH.DATA_TYPES.TASK) { @@ -5812,6 +5862,15 @@ function getColumnsToShow({ // Only update when we have custom columns to filter (customResult) or in expense report view, // so that the default search page path doesn't show extra columns. if (customResult || isExpenseReportView) { + if (customResult) { + const reportForCustomColumns = Array.isArray(data) ? report : (getReportOrDraftReport(transaction.reportID) ?? data[`${ONYXKEYS.COLLECTION.REPORT}${transaction.reportID}`]); + for (const column of reportCustomColumns) { + if (hasReportCustomColumnValue(column, reportForCustomColumns)) { + columns[column] = true; + } + } + } + if (transaction.cardName && transaction.cardName !== CONST.EXPENSE.TYPE.CASH_CARD_NAME) { columns[CONST.SEARCH.TABLE_COLUMNS.CARD] = true; } diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 23d4526eb7e2..51950ca27ad6 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -46,7 +46,7 @@ import { isInvoiceReport, isIOUReport as isIOUReportUtil, } from '@libs/ReportUtils'; -import {serializeQueryJSONForBackend} from '@libs/SearchQueryUtils'; +import {buildSearchQueryString, serializeQueryJSONForBackend} from '@libs/SearchQueryUtils'; import type {SearchKey} from '@libs/SearchUIUtils'; import {isTransactionGroupListItemType} from '@libs/SearchUIUtils'; import playSound, {SOUNDS} from '@libs/Sound'; @@ -101,6 +101,10 @@ type TransactionPreviewData = { hasTransactionThreadReport: boolean; }; +function shouldUseBackendDateSortFallback(sortBy: SearchQueryJSON['sortBy']): boolean { + return sortBy === CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID || sortBy === CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID || sortBy === CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS; +} + function getChatReportForSearchPay(chatReport: OnyxEntry, snapshotReport: Report, searchData?: SearchResultDataType): OnyxEntry { const chatReportID = snapshotReport.chatReportID ?? snapshotReport.parentReportID; const snapshotChatReport = chatReportID ? searchData?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`] : undefined; @@ -791,11 +795,21 @@ function search({ const {optimisticData, finallyData, failureData} = getOnyxLoadingData(queryJSON.hash, queryJSON, offset, isOffline, true, shouldCalculateTotals); const {flatFilters, limit, ...queryJSONWithoutFlatFilters} = queryJSON; + const backendQueryJSON = shouldUseBackendDateSortFallback(queryJSON.sortBy) + ? { + ...queryJSONWithoutFlatFilters, + sortBy: CONST.SEARCH.TABLE_COLUMNS.DATE, + inputQuery: buildSearchQueryString({...queryJSON, sortBy: CONST.SEARCH.TABLE_COLUMNS.DATE}), + rawFilterList: queryJSONWithoutFlatFilters.rawFilterList?.map((filter) => + filter.key === CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY ? {...filter, value: CONST.SEARCH.TABLE_COLUMNS.DATE} : filter, + ), + } + : queryJSONWithoutFlatFilters; const query = { - ...queryJSONWithoutFlatFilters, + ...backendQueryJSON, searchKey, offset, - filters: queryJSONWithoutFlatFilters.filters ?? null, + filters: backendQueryJSON.filters ?? null, shouldCalculateTotals, // Backend expects 'maximumResults' instead of 'limit' ...(limit !== undefined && {maximumResults: limit}), diff --git a/src/pages/settings/Report/ReportDetailsColumnsPage.tsx b/src/pages/settings/Report/ReportDetailsColumnsPage.tsx index 8e32293acaf9..91eccdaeffbc 100644 --- a/src/pages/settings/Report/ReportDetailsColumnsPage.tsx +++ b/src/pages/settings/Report/ReportDetailsColumnsPage.tsx @@ -77,6 +77,7 @@ function ReportDetailsColumnsPage() { const visibleColumns = getColumnsToShow({ currentAccountID: currentUserDetails?.accountID, data: reportTransactions, + report, isExpenseReportView: true, isExpenseReportViewFromIOUReport: isIOUReport(report), shouldShowBillableColumn: isBillableEnabledOnPolicy(policy), diff --git a/src/selectors/Report.ts b/src/selectors/Report.ts index 2d21083edef2..a36f27fc0e59 100644 --- a/src/selectors/Report.ts +++ b/src/selectors/Report.ts @@ -141,6 +141,9 @@ function getStableReportSelector(report: OnyxEntry) { created: report.created, submitted: report.submitted, approved: report.approved, + submitterUserID: report.submitterUserID, + submitterPayrollID: report.submitterPayrollID, + orderDealNumbers: report.orderDealNumbers, chatType: report.chatType, hasOutstandingChildRequest: report.hasOutstandingChildRequest, hasOutstandingChildTask: report.hasOutstandingChildTask, diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index bf057c634fd8..131c8e1327d7 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -1978,6 +1978,9 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ case CONST.SEARCH.TABLE_COLUMNS.FEED: case CONST.SEARCH.TABLE_COLUMNS.BANK_ACCOUNT: case CONST.SEARCH.TABLE_COLUMNS.WITHDRAWAL_ID: + case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_USER_ID: + case CONST.SEARCH.TABLE_COLUMNS.SUBMITTER_PAYROLL_ID: + case CONST.SEARCH.TABLE_COLUMNS.ORDER_DEAL_NUMBERS: case CONST.SEARCH.TABLE_COLUMNS.POLICY_NAME: case CONST.SEARCH.TABLE_COLUMNS.CARD: case CONST.SEARCH.TABLE_COLUMNS.REPORT_ID: diff --git a/src/types/form/DebugReportForm.ts b/src/types/form/DebugReportForm.ts index 3d4ffec4bfa6..9afdac7285a0 100644 --- a/src/types/form/DebugReportForm.ts +++ b/src/types/form/DebugReportForm.ts @@ -26,6 +26,7 @@ const INPUT_IDS = { NON_REIMBURSABLE_TOTAL: 'nonReimbursableTotal', NOTIFICATION_PREFERENCE: 'notificationPreference', OLD_POLICY_NAME: 'oldPolicyName', + ORDER_DEAL_NUMBERS: 'orderDealNumbers', OWNER_ACCOUNT_ID: 'ownerAccountID', PARTICIPANTS: 'participants', PERMISSIONS: 'permissions', @@ -38,6 +39,8 @@ const INPUT_IDS = { REPORT_NAME: 'reportName', STATE_NUM: 'stateNum', STATUS_NUM: 'statusNum', + SUBMITTER_PAYROLL_ID: 'submitterPayrollID', + SUBMITTER_USER_ID: 'submitterUserID', TOTAL: 'total', TYPE: 'type', UNHELD_TOTAL: 'unheldTotal', @@ -74,6 +77,7 @@ type DebugReportForm = Form< [INPUT_IDS.NON_REIMBURSABLE_TOTAL]: string; [INPUT_IDS.NOTIFICATION_PREFERENCE]: ValueOf; [INPUT_IDS.OLD_POLICY_NAME]: string; + [INPUT_IDS.ORDER_DEAL_NUMBERS]: string; [INPUT_IDS.OWNER_ACCOUNT_ID]: string; [INPUT_IDS.PARTICIPANTS]: string; [INPUT_IDS.PERMISSIONS]: string; @@ -86,6 +90,8 @@ type DebugReportForm = Form< [INPUT_IDS.REPORT_NAME]: string; [INPUT_IDS.STATE_NUM]: string; [INPUT_IDS.STATUS_NUM]: string; + [INPUT_IDS.SUBMITTER_PAYROLL_ID]: string; + [INPUT_IDS.SUBMITTER_USER_ID]: string; [INPUT_IDS.TOTAL]: string; [INPUT_IDS.TYPE]: ValueOf; [INPUT_IDS.UNHELD_TOTAL]: string; diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 9469059b2a91..f0a1523ca717 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -98,6 +98,15 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** The date the report was approved */ approved?: string; + /** Custom field 1 value for the report submitter */ + submitterUserID?: string; + + /** Custom field 2 value for the report submitter */ + submitterPayrollID?: string; + + /** International reimbursement IDs associated with the report */ + orderDealNumbers?: string; + /** The specific type of chat */ chatType?: ValueOf; diff --git a/src/types/utils/whitelistedReportKeys.ts b/src/types/utils/whitelistedReportKeys.ts index 873b144c0979..27bb15ba0563 100644 --- a/src/types/utils/whitelistedReportKeys.ts +++ b/src/types/utils/whitelistedReportKeys.ts @@ -34,6 +34,9 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback< created: unknown; submitted: unknown; approved: unknown; + submitterUserID: unknown; + submitterPayrollID: unknown; + orderDealNumbers: unknown; visibility: unknown; invoiceReceiver: unknown; parentReportID: unknown; diff --git a/tests/unit/Search/__snapshots__/ColumnAvailabilityTest.ts.snap b/tests/unit/Search/__snapshots__/ColumnAvailabilityTest.ts.snap index 097902238eb0..0c403133233d 100644 --- a/tests/unit/Search/__snapshots__/ColumnAvailabilityTest.ts.snap +++ b/tests/unit/Search/__snapshots__/ColumnAvailabilityTest.ts.snap @@ -24,6 +24,9 @@ exports[`Column availability single source of truth the derived picker lists mat "amount", "total", "withdrawalID", + "submitterUserID", + "submitterPayrollID", + "orderDealNumbers", ] `; @@ -62,5 +65,8 @@ exports[`Column availability single source of truth the derived picker lists mat "exportedto", "action", "withdrawalID", + "submitterUserID", + "submitterPayrollID", + "orderDealNumbers", ] `;