From 5dc7ec2e8f9cc835c35986daedde182f74c7c303 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 5 Aug 2026 14:27:18 +0700 Subject: [PATCH 1/3] Add Canadian Multiple Tax Export template to New Expensify for workspaces using CAD --- src/CONST/index.ts | 2 + .../FilterComponents/ExportedToSelector.tsx | 12 +-- .../SearchList/ListItem/ExportedIconCell.tsx | 5 +- src/hooks/useExportedToFilterOptions.ts | 2 +- src/hooks/useSearchBulkActions.ts | 14 ++++ src/languages/de.ts | 1 + src/languages/el.ts | 1 + src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/languages/fr.ts | 1 + src/languages/it.ts | 1 + src/languages/ja.ts | 1 + src/languages/nl.ts | 1 + src/languages/pl.ts | 1 + src/languages/pt-BR.ts | 1 + src/languages/zh-hans.ts | 1 + src/libs/AccountingUtils.ts | 22 +++++- src/libs/actions/Search.ts | 8 ++ tests/unit/SearchActionsTest.ts | 28 ++++++- tests/unit/SearchAutocompleteUtilsTest.ts | 30 +++++++- .../hooks/useSearchBulkActionsExportTest.ts | 76 +++++++++++++++++++ 21 files changed, 195 insertions(+), 15 deletions(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 78cb558365e7..78aa026e7b18 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1948,10 +1948,12 @@ const CONST = { DOWNLOAD_CSV: 'downloadCSV', REPORT_LEVEL_EXPORT: 'report_level_export', EXPENSE_LEVEL_EXPORT: 'detailed_export', + MULTIPLE_TAX_EXPORT: 'multiple_tax_export', }, EXPORT_OPTION_LABELS: { REPORT_LEVEL_EXPORT: 'All Data - Report Level Export', EXPENSE_LEVEL_EXPORT: 'All Data - Expense Level Export', + MULTIPLE_TAX_EXPORT: 'Canadian Multiple Tax Export', DEFAULT_CSV: 'Default CSV', }, ROOM_MEMBERS_BULK_ACTION_TYPES: { diff --git a/src/components/Search/FilterComponents/ExportedToSelector.tsx b/src/components/Search/FilterComponents/ExportedToSelector.tsx index d062414b6967..946b1356376f 100644 --- a/src/components/Search/FilterComponents/ExportedToSelector.tsx +++ b/src/components/Search/FilterComponents/ExportedToSelector.tsx @@ -9,7 +9,7 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import {getSearchValueForConnection} from '@libs/AccountingUtils'; +import {getSearchValueForConnection, getStandardExportTemplateDisplayName, isStandardExportTemplate} from '@libs/AccountingUtils'; import {getIntegrationIcon} from '@libs/ReportUtils'; import {getAllPolicyValues, getConnectedIntegrationNamesForPolicies} from '@libs/SearchQueryUtils'; @@ -28,11 +28,6 @@ type ExportedToSelectorProps = SearchFilterCommonProps & { policyID: Filter | undefined; }; -const STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL: Record = { - [CONST.REPORT.EXPORT_OPTIONS.REPORT_LEVEL_EXPORT]: CONST.REPORT.EXPORT_OPTION_LABELS.REPORT_LEVEL_EXPORT, - [CONST.REPORT.EXPORT_OPTIONS.EXPENSE_LEVEL_EXPORT]: CONST.REPORT.EXPORT_OPTION_LABELS.EXPENSE_LEVEL_EXPORT, -}; - function ExportedToSelector({value = [], policyID, selectionListTextInputStyle, selectionListStyle, autoFocus, footer, onChange}: ExportedToSelectorProps) { const styles = useThemeStyles(); const {localeCompare} = useLocalize(); @@ -105,13 +100,14 @@ function ExportedToSelector({value = [], policyID, selectionListTextInputStyle, } const displayName = template.name ?? template.templateName ?? ''; - const filterValue = STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName] ?? displayName; + // Standard templates are filtered on by the label the backend records for them, while custom templates are filtered on by their display name + const isStandardTemplate = isStandardExportTemplate(template.templateName); + const filterValue = isStandardTemplate ? getStandardExportTemplateDisplayName(template.templateName) : displayName; if (usedPickerValueKeys.has(filterValue)) { continue; } usedPickerValueKeys.add(filterValue); - const isStandardTemplate = !!STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName]; standardAndIntegrationCustomTemplatePickerItems.push({ text: displayName, value: filterValue, diff --git a/src/components/Search/SearchList/ListItem/ExportedIconCell.tsx b/src/components/Search/SearchList/ListItem/ExportedIconCell.tsx index e093b7d60149..03ab171a0976 100644 --- a/src/components/Search/SearchList/ListItem/ExportedIconCell.tsx +++ b/src/components/Search/SearchList/ListItem/ExportedIconCell.tsx @@ -5,6 +5,7 @@ import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import {isStandardExportTemplateLabel} from '@libs/AccountingUtils'; import {getOriginalMessage, isExportedToIntegrationAction} from '@libs/ReportActionsUtils'; import CONST from '@src/CONST'; @@ -17,8 +18,6 @@ type ExportedIconCellProps = { reportActions?: ReportAction[]; }; -const STANDARD_EXPORT_TEMPLATE_LABELS = new Set([CONST.REPORT.EXPORT_OPTION_LABELS.EXPENSE_LEVEL_EXPORT, CONST.REPORT.EXPORT_OPTION_LABELS.REPORT_LEVEL_EXPORT]); - function ExportedIconCell({reportActions}: ExportedIconCellProps) { const theme = useTheme(); const styles = useThemeStyles(); @@ -58,7 +57,7 @@ function ExportedIconCell({reportActions}: ExportedIconCellProps) { const message = getOriginalMessage(action); const label = message?.label; const type = message?.type; - const isStandardExportTemplate = !!label && STANDARD_EXPORT_TEMPLATE_LABELS.has(label); + const isStandardExportTemplate = !!label && isStandardExportTemplateLabel(label); if (type === CONST.EXPORT_TEMPLATE && isStandardExportTemplate) { isExportedToStandardTemplate = true; diff --git a/src/hooks/useExportedToFilterOptions.ts b/src/hooks/useExportedToFilterOptions.ts index e770d777c50b..59c862e12752 100644 --- a/src/hooks/useExportedToFilterOptions.ts +++ b/src/hooks/useExportedToFilterOptions.ts @@ -31,7 +31,7 @@ function exportedToPoliciesSelector(policies: OnyxCollection): OnyxColle if (!policy) { continue; } - result[key] = {id: policy.id, name: policy.name, connections: policy.connections, exportLayouts: policy.exportLayouts} as Policy; + result[key] = {id: policy.id, name: policy.name, connections: policy.connections, exportLayouts: policy.exportLayouts, outputCurrency: policy.outputCurrency} as Policy; } return result; } diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 110a884fc453..2ab4dddf70ce 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -534,6 +534,18 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { ], [selectedTransactions], ); + + // A bulk selection can span several workspaces, so the Canadian Multiple Tax Export template is only offered when every selected item belongs to a workspace that outputs in CAD. + // Reports and transactions are both checked because a selection can mix whole reports with individual transactions from other reports, and the export request covers all of them. + const doAllSelectedItemsBelongToCADPolicies = useMemo(() => { + const selectedItems = [...selectedReports, ...Object.values(selectedTransactions)]; + if (selectedItems.length === 0) { + return false; + } + + return selectedItems.every((item) => !!item.policyID && policies?.[`${ONYXKEYS.COLLECTION.POLICY}${item.policyID}`]?.outputCurrency === CONST.CURRENCY.CAD); + }, [selectedReports, selectedTransactions, policies]); + const selectedBulkCurrency = selectedReports.at(0)?.currency ?? Object.values(selectedTransactions).at(0)?.currency; const totalFormattedAmount = getTotalFormattedAmount(convertToDisplayString, selectedReports, selectedTransactions, selectedBulkCurrency); @@ -1638,6 +1650,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { policy, includeReportLevelExport, !isGroupedSearch, + doAllSelectedItemsBelongToCADPolicies, ); const exportOptions: PopoverMenuItem[] = []; @@ -2436,6 +2449,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { personalPolicy?.outputCurrency, restrictedActionPolicyID, doSelectedItemsBelongToSubmitPolicy, + doAllSelectedItemsBelongToCADPolicies, openSearchReportSubmitToPopover, deleteTransactionsFromHook, duplicateTransactionViolations, diff --git a/src/languages/de.ts b/src/languages/de.ts index 3ef9c6344aa1..d0991c549c73 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -10392,6 +10392,7 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, basicExport: 'Standardexport', reportLevelExport: 'Alle Daten – Berichtsebene', expenseLevelExport: 'Alle Daten – Ausgabenebene', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: 'Export wird ausgeführt', conciergeWillSend: 'Concierge wird dir die Datei in Kürze senden.', currentView: 'Aktuelle Ansicht', diff --git a/src/languages/el.ts b/src/languages/el.ts index 295f7522075e..4391e63ad2cd 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -10612,6 +10612,7 @@ ${reportName}`, currentView: 'Τρέχουσα προβολή', reportLevelExport: 'Όλα τα δεδομένα - σε επίπεδο αναφοράς', expenseLevelExport: 'Όλα τα δεδομένα - επίπεδο δαπάνης', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: 'Εξαγωγή σε εξέλιξη', conciergeWillSend: 'Ο Concierge θα σας στείλει το αρχείο σύντομα.', downloadStatementPDF: 'Λήψη κατάστασης', diff --git a/src/languages/en.ts b/src/languages/en.ts index f08c20f1c637..91a6c4fc24e8 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -10548,6 +10548,7 @@ const translations = { currentView: 'Current view', reportLevelExport: 'All Data - report level', expenseLevelExport: 'All Data - expense level', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: 'Export in progress', conciergeWillSend: 'Concierge will send you the file shortly.', }, diff --git a/src/languages/es.ts b/src/languages/es.ts index 81460fbe2551..10a973e7a9bc 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -10550,6 +10550,7 @@ El plan Controlar empieza en 9 $ por miembro activo al mes.`, basicExport: 'Exportar básico', reportLevelExport: 'Todos los datos - a nivel de informe', expenseLevelExport: 'Todos los datos - a nivel de gasto', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: 'Exportación en curso', conciergeWillSend: 'Concierge te enviará el archivo en breve.', currentView: 'Vista actual', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 540fbc57d0e8..e27e999b89df 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -10426,6 +10426,7 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, basicExport: 'Export basique', reportLevelExport: 'Toutes les données - niveau note de frais', expenseLevelExport: 'Toutes les données - niveau dépense', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: 'Export en cours', conciergeWillSend: 'Concierge vous enverra le fichier sous peu.', currentView: 'Vue actuelle', diff --git a/src/languages/it.ts b/src/languages/it.ts index 287b84acb49c..cf6c4b48a409 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -10368,6 +10368,7 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, basicExport: 'Esportazione di base', reportLevelExport: 'Tutti i dati - livello report', expenseLevelExport: 'Tutti i dati - livello spesa', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: 'Esportazione in corso', conciergeWillSend: 'Concierge ti invierà il file a breve.', currentView: 'Vista corrente', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 9861a6dafdbd..b5cb7e254633 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -10228,6 +10228,7 @@ ${reportName}`, basicExport: '基本エクスポート', reportLevelExport: 'すべてのデータ - レポートレベル', expenseLevelExport: 'すべてのデータ - 経費レベル', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: 'エクスポート処理中', conciergeWillSend: 'Conciergeがまもなくファイルを送信します。', currentView: '現在のビュー', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 2c73d883b8df..0ef89e0a32c9 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -10338,6 +10338,7 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, basicExport: 'Standaardexport', reportLevelExport: 'Alle gegevens - rapportniveau', expenseLevelExport: 'Alle gegevens - uitgaveniveau', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: 'Export bezig', conciergeWillSend: 'Concierge stuurt je het bestand zo meteen.', currentView: 'Huidige weergave', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 0851de6bd99d..cbe6f9a63725 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -10307,6 +10307,7 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, basicExport: 'Podstawowy eksport', reportLevelExport: 'Wszystkie dane – poziom raportu', expenseLevelExport: 'Wszystkie dane – poziom wydatku', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: 'Trwa eksport', conciergeWillSend: 'Concierge wkrótce wyśle Ci plik.', currentView: 'Bieżący widok', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 5edd411976e5..d755a20e994d 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -10326,6 +10326,7 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, basicExport: 'Exportação básica', reportLevelExport: 'Todos os dados - nível de relatório', expenseLevelExport: 'Todos os dados - nível de despesa', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: 'Exportação em andamento', conciergeWillSend: 'O Concierge enviará o arquivo para você em breve.', currentView: 'Visualização atual', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 3672b252bc7c..ee4798c12823 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -9989,6 +9989,7 @@ ${reportName}`, basicExport: '基本导出', reportLevelExport: '所有数据 - 报告级别', expenseLevelExport: '所有数据 - 报销级别', + multipleTaxExport: 'Canadian Multiple Tax Export', exportInProgress: '导出进行中', conciergeWillSend: 'Concierge 将很快把文件发送给你。', currentView: '当前视图', diff --git a/src/libs/AccountingUtils.ts b/src/libs/AccountingUtils.ts index 6665ee3a4e5b..d30609256230 100644 --- a/src/libs/AccountingUtils.ts +++ b/src/libs/AccountingUtils.ts @@ -32,8 +32,11 @@ const NAME_ROUTE_MAPPING = { const STANDARD_EXPORT_TEMPLATE_NAME_MAPPING = { [CONST.REPORT.EXPORT_OPTIONS.EXPENSE_LEVEL_EXPORT]: CONST.REPORT.EXPORT_OPTION_LABELS.EXPENSE_LEVEL_EXPORT, [CONST.REPORT.EXPORT_OPTIONS.REPORT_LEVEL_EXPORT]: CONST.REPORT.EXPORT_OPTION_LABELS.REPORT_LEVEL_EXPORT, + [CONST.REPORT.EXPORT_OPTIONS.MULTIPLE_TAX_EXPORT]: CONST.REPORT.EXPORT_OPTION_LABELS.MULTIPLE_TAX_EXPORT, }; +const STANDARD_EXPORT_TEMPLATE_LABELS = new Set(Object.values(STANDARD_EXPORT_TEMPLATE_NAME_MAPPING)); + function getConnectionNameFromRouteParam(routeParam: ValueOf) { return ROUTE_NAME_MAPPING[routeParam]; } @@ -50,4 +53,21 @@ function getStandardExportTemplateDisplayName(templateName: string): string { return STANDARD_EXPORT_TEMPLATE_NAME_MAPPING[templateName as keyof typeof STANDARD_EXPORT_TEMPLATE_NAME_MAPPING] ?? templateName; } -export {getConnectionNameFromRouteParam, getRouteParamForConnection, getSearchValueForConnection, getStandardExportTemplateDisplayName}; +/** Whether the given template ID belongs to one of the standard (i.e. not user-defined) export templates */ +function isStandardExportTemplate(templateName: string): boolean { + return templateName in STANDARD_EXPORT_TEMPLATE_NAME_MAPPING; +} + +/** Whether the given export label, as sent by the backend on an export report action, belongs to one of the standard (i.e. not user-defined) export templates */ +function isStandardExportTemplateLabel(label: string): boolean { + return STANDARD_EXPORT_TEMPLATE_LABELS.has(label); +} + +export { + getConnectionNameFromRouteParam, + getRouteParamForConnection, + getSearchValueForConnection, + getStandardExportTemplateDisplayName, + isStandardExportTemplate, + isStandardExportTemplateLabel, +}; diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 4e30fc376e0b..b88579d58c08 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -1718,6 +1718,8 @@ type ExportTemplateGroups = { * @param policy - The user's policy * @param includeReportLevelExport - Whether to include the report level export template * @param includeBasicExport - Whether to include the basic export (CSV download) template in the default group + * @param includeMultipleTaxExport - Whether to include the Canadian Multiple Tax Export template. Defaults to whether the given policy outputs in CAD, so callers that + * export across several workspaces (e.g. a bulk selection in Search) can instead pass whether every selected workspace outputs in CAD. * @returns The export templates pre-grouped into the custom group and the default group, each sorted alphabetically */ function getExportTemplates( @@ -1728,6 +1730,7 @@ function getExportTemplates( policy?: Policy, includeReportLevelExport = true, includeBasicExport = false, + includeMultipleTaxExport = policy?.outputCurrency === CONST.CURRENCY.CAD, ): ExportTemplateGroups { // Helper function to normalize template data into consistent ExportTemplate format const normalizeTemplate = ( @@ -1754,6 +1757,11 @@ function getExportTemplates( exportTemplates.push(normalizeTemplate(CONST.REPORT.EXPORT_OPTIONS.REPORT_LEVEL_EXPORT, {name: translate('export.reportLevelExport')}, CONST.EXPORT_TEMPLATE_TYPES.INTEGRATIONS)); } + // The Canadian Multiple Tax Export template is only relevant to workspaces that output in CAD, so it's hidden for every other currency + if (includeMultipleTaxExport) { + exportTemplates.push(normalizeTemplate(CONST.REPORT.EXPORT_OPTIONS.MULTIPLE_TAX_EXPORT, {name: translate('export.multipleTaxExport')}, CONST.EXPORT_TEMPLATE_TYPES.INTEGRATIONS)); + } + // Conditionally include the basic export (CSV download) template so it's sorted alphabetically alongside the other default templates if (includeBasicExport) { exportTemplates.push(normalizeTemplate(CONST.REPORT.EXPORT_OPTIONS.DOWNLOAD_CSV, {name: translate('export.basicExport')}, CONST.EXPORT_TEMPLATE_TYPES.INTEGRATIONS)); diff --git a/tests/unit/SearchActionsTest.ts b/tests/unit/SearchActionsTest.ts index 3c97f151279e..f4c7805e6c1f 100644 --- a/tests/unit/SearchActionsTest.ts +++ b/tests/unit/SearchActionsTest.ts @@ -6,9 +6,10 @@ import type {SearchKey} from '@libs/SearchUIUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {ExportTemplate} from '@src/types/onyx'; +import type {ExportTemplate, Policy} from '@src/types/onyx'; import type {AnyOnyxUpdate} from '@src/types/onyx/Request'; +import createRandomPolicy from '../utils/collections/policies'; import {translateLocal} from '../utils/TestHelper'; jest.mock('@libs/API'); @@ -219,6 +220,7 @@ describe('getExportTemplates', () => { const translate = translateLocal; const localeCompare = (first: string, second: string) => first.localeCompare(second); const makeTemplate = (name: string): ExportTemplate => ({name, templateName: name, type: '', policyID: undefined, description: ''}); + const makePolicyWithOutputCurrency = (outputCurrency: string): Policy => ({...createRandomPolicy(1), outputCurrency}); it('returns the custom templates and the default templates as separate groups, each sorted alphabetically', () => { const integrationsExportTemplates: ExportTemplate[] = [makeTemplate('Zebra integration'), makeTemplate('Apple integration')]; @@ -258,4 +260,28 @@ describe('getExportTemplates', () => { // Basic export is sorted alphabetically alongside the other default templates, not pinned to the bottom expect(names).toEqual([translate('export.expenseLevelExport'), translate('export.reportLevelExport'), translate('export.basicExport')].sort(localeCompare)); }); + + it('includes the Canadian Multiple Tax Export template when the policy outputs in CAD', () => { + const {defaultTemplates} = getExportTemplates([], {}, translate, localeCompare, makePolicyWithOutputCurrency(CONST.CURRENCY.CAD)); + + expect(defaultTemplates.map((template) => template.templateName)).toContain(CONST.REPORT.EXPORT_OPTIONS.MULTIPLE_TAX_EXPORT); + }); + + it('excludes the Canadian Multiple Tax Export template when the policy outputs in another currency', () => { + const {defaultTemplates} = getExportTemplates([], {}, translate, localeCompare, makePolicyWithOutputCurrency(CONST.CURRENCY.USD)); + + expect(defaultTemplates.map((template) => template.templateName)).not.toContain(CONST.REPORT.EXPORT_OPTIONS.MULTIPLE_TAX_EXPORT); + }); + + it('includes the Canadian Multiple Tax Export template when includeMultipleTaxExport is true without a policy', () => { + const {defaultTemplates} = getExportTemplates([], {}, translate, localeCompare, undefined, true, false, true); + + expect(defaultTemplates.map((template) => template.templateName)).toContain(CONST.REPORT.EXPORT_OPTIONS.MULTIPLE_TAX_EXPORT); + }); + + it('excludes the Canadian Multiple Tax Export template when includeMultipleTaxExport is false for a CAD policy', () => { + const {defaultTemplates} = getExportTemplates([], {}, translate, localeCompare, makePolicyWithOutputCurrency(CONST.CURRENCY.CAD), true, false, false); + + expect(defaultTemplates.map((template) => template.templateName)).not.toContain(CONST.REPORT.EXPORT_OPTIONS.MULTIPLE_TAX_EXPORT); + }); }); diff --git a/tests/unit/SearchAutocompleteUtilsTest.ts b/tests/unit/SearchAutocompleteUtilsTest.ts index f0b28ea709df..759d48acc635 100644 --- a/tests/unit/SearchAutocompleteUtilsTest.ts +++ b/tests/unit/SearchAutocompleteUtilsTest.ts @@ -1,6 +1,6 @@ import type {SubstitutionMap} from '@components/Search/SearchRouter/getQueryWithSubstitutions'; -import {getSearchValueForConnection, getStandardExportTemplateDisplayName} from '@libs/AccountingUtils'; +import {getSearchValueForConnection, getStandardExportTemplateDisplayName, isStandardExportTemplate, isStandardExportTemplateLabel} from '@libs/AccountingUtils'; import {getTrimmedUserSearchQueryPreservingComma, parseForLiveMarkdown} from '@libs/SearchAutocompleteUtils'; import CONST from '@src/CONST'; @@ -554,10 +554,38 @@ describe('SearchAutocompleteUtils', () => { expect(getStandardExportTemplateDisplayName(CONST.REPORT.EXPORT_OPTIONS.REPORT_LEVEL_EXPORT)).toBe(CONST.REPORT.EXPORT_OPTION_LABELS.REPORT_LEVEL_EXPORT); }); + it('returns display name for the Canadian multiple tax export template', () => { + expect(getStandardExportTemplateDisplayName(CONST.REPORT.EXPORT_OPTIONS.MULTIPLE_TAX_EXPORT)).toBe(CONST.REPORT.EXPORT_OPTION_LABELS.MULTIPLE_TAX_EXPORT); + }); + it('returns template name as-is when no standard mapping', () => { const customName = 'Custom Export Layout'; expect(getStandardExportTemplateDisplayName(customName)).toBe(customName); }); }); + + describe('isStandardExportTemplate', () => { + it('returns true for every standard export template ID', () => { + expect(isStandardExportTemplate(CONST.REPORT.EXPORT_OPTIONS.EXPENSE_LEVEL_EXPORT)).toBe(true); + expect(isStandardExportTemplate(CONST.REPORT.EXPORT_OPTIONS.REPORT_LEVEL_EXPORT)).toBe(true); + expect(isStandardExportTemplate(CONST.REPORT.EXPORT_OPTIONS.MULTIPLE_TAX_EXPORT)).toBe(true); + }); + + it('returns false for a custom template ID', () => { + expect(isStandardExportTemplate('Custom Export Layout')).toBe(false); + }); + }); + + describe('isStandardExportTemplateLabel', () => { + it('returns true for every standard export template label', () => { + expect(isStandardExportTemplateLabel(CONST.REPORT.EXPORT_OPTION_LABELS.EXPENSE_LEVEL_EXPORT)).toBe(true); + expect(isStandardExportTemplateLabel(CONST.REPORT.EXPORT_OPTION_LABELS.REPORT_LEVEL_EXPORT)).toBe(true); + expect(isStandardExportTemplateLabel(CONST.REPORT.EXPORT_OPTION_LABELS.MULTIPLE_TAX_EXPORT)).toBe(true); + }); + + it('returns false for a custom template label', () => { + expect(isStandardExportTemplateLabel('Custom Export Layout')).toBe(false); + }); + }); }); }); diff --git a/tests/unit/hooks/useSearchBulkActionsExportTest.ts b/tests/unit/hooks/useSearchBulkActionsExportTest.ts index da40cbeddfbf..d91c57984197 100644 --- a/tests/unit/hooks/useSearchBulkActionsExportTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsExportTest.ts @@ -5,6 +5,7 @@ import type {SearchQueryJSON, SelectedReports, SelectedTransactions} from '@comp import useSearchBulkActions from '@hooks/useSearchBulkActions'; +import {getExportTemplates} from '@libs/actions/Search'; import type * as ReportSecondaryActionUtilsModule from '@libs/ReportSecondaryActionUtils'; import CONST from '@src/CONST'; @@ -229,6 +230,8 @@ jest.mock('@components/Search/SearchContext', () => ({ }), })); +const mockGetExportTemplates = jest.mocked(getExportTemplates); + const CURRENT_USER_ACCOUNT_ID = 1; jest.mock('@hooks/useCurrentUserPersonalDetails', () => ({ @@ -486,4 +489,77 @@ describe('useSearchBulkActions - export options', () => { expect(getExportOptionTexts(result.current.headerButtonsOptions)).toEqual(['export.currentView']); }); }); + + describe('Canadian Multiple Tax Export eligibility', () => { + const SECOND_POLICY_ID = 'policy2'; + const SECOND_REPORT_ID = 'report2'; + + /** The includeMultipleTaxExport argument getExportTemplates was last called with */ + function getIncludeMultipleTaxExportArgument() { + return mockGetExportTemplates.mock.calls.at(-1)?.at(7); + } + + beforeEach(async () => { + await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${POLICY_ID}`, {outputCurrency: CONST.CURRENCY.CAD}); + }); + + it('offers the template when every selected workspace outputs in CAD, even across several workspaces', async () => { + await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${SECOND_POLICY_ID}`, {id: SECOND_POLICY_ID, outputCurrency: CONST.CURRENCY.CAD}); + + mockCurrentSearchResults = makeSearchResults([makeSnapshotReport()]); + mockSelectedReports = [makeSelectedReport(), makeSelectedReport({reportID: SECOND_REPORT_ID, policyID: SECOND_POLICY_ID})]; + mockSelectedTransactions = { + tx1: makeSelectedTransaction(), + tx2: makeSelectedTransaction({reportID: SECOND_REPORT_ID, policyID: SECOND_POLICY_ID}), + }; + + renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(getIncludeMultipleTaxExportArgument()).toBe(true); + }); + }); + + it('hides the template when a transaction from a non-CAD workspace is selected alongside a CAD report', async () => { + await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${SECOND_POLICY_ID}`, {id: SECOND_POLICY_ID, outputCurrency: CONST.CURRENCY.USD}); + + mockCurrentSearchResults = makeSearchResults([makeSnapshotReport()]); + // Only the CAD report is fully selected, but an extra transaction from a USD workspace is part of the same export request + mockSelectedReports = [makeSelectedReport()]; + mockSelectedTransactions = { + tx1: makeSelectedTransaction(), + tx2: makeSelectedTransaction({reportID: SECOND_REPORT_ID, policyID: SECOND_POLICY_ID}), + }; + + renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(mockGetExportTemplates).toHaveBeenCalled(); + }); + expect(getIncludeMultipleTaxExportArgument()).toBe(false); + }); + + it('hides the template when a self DM expense is selected alongside a CAD workspace expense', async () => { + const expenseQueryJSON: SearchQueryJSON = { + ...expenseReportQueryJSON, + inputQuery: 'type:expense status:all', + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + }; + + mockCurrentSearchResults = makeSearchResults([makeSnapshotReport()]); + mockSelectedReports = []; + mockSelectedTransactions = { + // A self DM expense sits outside any workspace, so its selection entry carries no policyID + selfDMTx: makeSelectedTransaction({reportID: SECOND_REPORT_ID, policyID: undefined, currency: 'USD'}), + workspaceTx: makeSelectedTransaction(), + }; + + renderHook(() => useSearchBulkActions({queryJSON: expenseQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(mockGetExportTemplates).toHaveBeenCalled(); + }); + expect(getIncludeMultipleTaxExportArgument()).toBe(false); + }); + }); }); From f88a3568a14caffa32843b39a44fe1ffdbfad741 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 5 Aug 2026 22:03:26 +0700 Subject: [PATCH 2/3] Hide CAD-only export for unverified select-all results --- src/hooks/useSearchBulkActions.ts | 13 +++- .../hooks/useSearchBulkActionsExportTest.ts | 65 ++++++++++++++++++- 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index 2ab4dddf70ce..5b96f125e900 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -63,7 +63,7 @@ import { isSelfDM, shouldShowMarkAsDone, } from '@libs/ReportUtils'; -import {buildSearchQueryJSON, buildSearchQueryString, isDefaultExpensesQuery, serializeQueryJSONForBackend} from '@libs/SearchQueryUtils'; +import {buildSearchQueryJSON, buildSearchQueryString, getFilterFromQuery, isDefaultExpensesQuery, serializeQueryJSONForBackend} from '@libs/SearchQueryUtils'; import {getColumnsToShow, getSearchColumnTranslationKey, getSelectedGroupFilterEntry, getValidGroupBy, navigateToSearchRHP, shouldShowDeleteOption} from '@libs/SearchUIUtils'; import showConfirmModalAfterMoreMenuDismiss from '@libs/showConfirmModalAfterMoreMenuDismiss'; import playSound, {SOUNDS} from '@libs/Sound'; @@ -538,13 +538,22 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { // A bulk selection can span several workspaces, so the Canadian Multiple Tax Export template is only offered when every selected item belongs to a workspace that outputs in CAD. // Reports and transactions are both checked because a selection can mix whole reports with individual transactions from other reports, and the export request covers all of them. const doAllSelectedItemsBelongToCADPolicies = useMemo(() => { + if (areAllMatchingItemsSelected) { + const policyIDFilter = getFilterFromQuery(queryJSON, CONST.SEARCH.SYNTAX_FILTER_KEYS.POLICY_ID); + if (!policyIDFilter.value?.length || policyIDFilter.isNegated) { + return false; + } + + return policyIDFilter.value.every((policyID) => policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]?.outputCurrency === CONST.CURRENCY.CAD); + } + const selectedItems = [...selectedReports, ...Object.values(selectedTransactions)]; if (selectedItems.length === 0) { return false; } return selectedItems.every((item) => !!item.policyID && policies?.[`${ONYXKEYS.COLLECTION.POLICY}${item.policyID}`]?.outputCurrency === CONST.CURRENCY.CAD); - }, [selectedReports, selectedTransactions, policies]); + }, [areAllMatchingItemsSelected, queryJSON, selectedReports, selectedTransactions, policies]); const selectedBulkCurrency = selectedReports.at(0)?.currency ?? Object.values(selectedTransactions).at(0)?.currency; const totalFormattedAmount = getTotalFormattedAmount(convertToDisplayString, selectedReports, selectedTransactions, selectedBulkCurrency); diff --git a/tests/unit/hooks/useSearchBulkActionsExportTest.ts b/tests/unit/hooks/useSearchBulkActionsExportTest.ts index d91c57984197..610aec26cff0 100644 --- a/tests/unit/hooks/useSearchBulkActionsExportTest.ts +++ b/tests/unit/hooks/useSearchBulkActionsExportTest.ts @@ -208,12 +208,13 @@ const mockSelectAllMatchingItems = jest.fn(); let mockSelectedTransactions: SelectedTransactions = {}; let mockSelectedReports: SelectedReports[] = []; let mockCurrentSearchResults: SearchResults | undefined; +let mockAreAllMatchingItemsSelected = false; jest.mock('@components/Search/SearchContext', () => ({ useSearchSelectionContext: () => ({ selectedTransactions: mockSelectedTransactions, selectedReports: mockSelectedReports, - areAllMatchingItemsSelected: false, + areAllMatchingItemsSelected: mockAreAllMatchingItemsSelected, }), useSearchResultsContext: () => ({ currentSearchResults: mockCurrentSearchResults, @@ -369,6 +370,7 @@ describe('useSearchBulkActions - export options', () => { mockSelectedTransactions = {}; mockSelectedReports = []; mockCurrentSearchResults = undefined; + mockAreAllMatchingItemsSelected = false; await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_USER_ACCOUNT_ID, email: 'test@example.com'}); // A policy connected to NetSuite so the integration export branch is reachable. @@ -561,5 +563,66 @@ describe('useSearchBulkActions - export options', () => { }); expect(getIncludeMultipleTaxExportArgument()).toBe(false); }); + + /** A query scoped to the given workspaces, as "Select all matching" would export it. */ + function policyScopedQueryJSON(policyIDs: string[]): SearchQueryJSON { + return { + ...expenseReportQueryJSON, + flatFilters: [ + { + key: CONST.SEARCH.SYNTAX_FILTER_KEYS.POLICY_ID, + filters: policyIDs.map((policyID) => ({operator: CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO, value: policyID})), + }, + ], + } as SearchQueryJSON; + } + + it('offers the template under select all when the query is scoped to CAD workspaces only', async () => { + await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${SECOND_POLICY_ID}`, {id: SECOND_POLICY_ID, outputCurrency: CONST.CURRENCY.CAD}); + mockAreAllMatchingItemsSelected = true; + + mockCurrentSearchResults = makeSearchResults([makeSnapshotReport()]); + mockSelectedReports = [makeSelectedReport()]; + mockSelectedTransactions = {tx1: makeSelectedTransaction()}; + + renderHook(() => useSearchBulkActions({queryJSON: policyScopedQueryJSON([POLICY_ID, SECOND_POLICY_ID])}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(getIncludeMultipleTaxExportArgument()).toBe(true); + }); + }); + + it('hides the template under select all when a workspace in the query scope is not CAD', async () => { + await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${SECOND_POLICY_ID}`, {id: SECOND_POLICY_ID, outputCurrency: CONST.CURRENCY.USD}); + mockAreAllMatchingItemsSelected = true; + + mockCurrentSearchResults = makeSearchResults([makeSnapshotReport()]); + // The loaded rows are all CAD, but the query also matches a USD workspace that hasn't been loaded yet + mockSelectedReports = [makeSelectedReport()]; + mockSelectedTransactions = {tx1: makeSelectedTransaction()}; + + renderHook(() => useSearchBulkActions({queryJSON: policyScopedQueryJSON([POLICY_ID, SECOND_POLICY_ID])}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(mockGetExportTemplates).toHaveBeenCalled(); + }); + expect(getIncludeMultipleTaxExportArgument()).toBe(false); + }); + + it('hides the template under select all when the query is not scoped to any workspace', async () => { + mockAreAllMatchingItemsSelected = true; + + mockCurrentSearchResults = makeSearchResults([makeSnapshotReport()]); + // Every loaded row is CAD, but an unscoped query can still match a non-CAD workspace further down the results + mockSelectedReports = [makeSelectedReport()]; + mockSelectedTransactions = {tx1: makeSelectedTransaction()}; + + renderHook(() => useSearchBulkActions({queryJSON: expenseReportQueryJSON}), {wrapper: OnyxListItemProvider}); + + await waitFor(() => { + expect(mockGetExportTemplates).toHaveBeenCalled(); + }); + expect(getIncludeMultipleTaxExportArgument()).toBe(false); + }); }); }); From 59fe21251262d60cfc8deaca2af688f8a503a6a1 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 11 Aug 2026 14:48:00 +0700 Subject: [PATCH 3/3] add translations --- .../FilterComponents/ExportedToSelector.tsx | 1 + src/languages/de.ts | 2 +- src/languages/el.ts | 2 +- src/languages/es.ts | 2 +- src/languages/fr.ts | 2 +- src/languages/it.ts | 2 +- src/languages/ja.ts | 2 +- src/languages/nl.ts | 2 +- src/languages/pl.ts | 2 +- src/languages/pt-BR.ts | 2 +- src/languages/zh-hans.ts | 2 +- src/libs/SearchQueryUtils.ts | 10 ++---- tests/unit/Search/SearchQueryUtilsTest.ts | 33 +++++++++++++++++++ 13 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/components/Search/FilterComponents/ExportedToSelector.tsx b/src/components/Search/FilterComponents/ExportedToSelector.tsx index d396603fccf7..8246cdbe393a 100644 --- a/src/components/Search/FilterComponents/ExportedToSelector.tsx +++ b/src/components/Search/FilterComponents/ExportedToSelector.tsx @@ -101,6 +101,7 @@ function ExportedToSelector({value = [], policyID, selectionListTextInputStyle, } const displayName = template.name ?? template.templateName ?? ''; + // Standard templates are filtered on by the label the backend records for them, while custom templates are filtered on by their display name const isStandardTemplate = isStandardExportTemplate(template.templateName); const filterValue = isStandardTemplate ? getStandardExportTemplateDisplayName(template.templateName) : displayName; diff --git a/src/languages/de.ts b/src/languages/de.ts index a6a488ea9541..c0d12ab1fe25 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -10438,7 +10438,7 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`, basicExport: 'Standardexport', reportLevelExport: 'Alle Daten – Berichtsebene', expenseLevelExport: 'Alle Daten – Ausgabenebene', - multipleTaxExport: 'Canadian Multiple Tax Export', + multipleTaxExport: 'Kanadischer Export mit mehreren Steuern', exportInProgress: 'Export wird ausgeführt', conciergeWillSend: 'Concierge wird dir die Datei in Kürze senden.', currentView: 'Aktuelle Ansicht', diff --git a/src/languages/el.ts b/src/languages/el.ts index d0cb954d7970..f94484c16e9b 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -10653,7 +10653,7 @@ ${reportName}`, currentView: 'Τρέχουσα προβολή', reportLevelExport: 'Όλα τα δεδομένα - σε επίπεδο αναφοράς', expenseLevelExport: 'Όλα τα δεδομένα - επίπεδο δαπάνης', - multipleTaxExport: 'Canadian Multiple Tax Export', + multipleTaxExport: 'Καναδική εξαγωγή πολλαπλών φόρων', exportInProgress: 'Εξαγωγή σε εξέλιξη', conciergeWillSend: 'Ο Concierge θα σας στείλει το αρχείο σύντομα.', downloadStatementPDF: 'Λήψη κατάστασης', diff --git a/src/languages/es.ts b/src/languages/es.ts index e39d9511e647..97a6289b9f62 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -10635,7 +10635,7 @@ El plan Controlar empieza en 9 $ por miembro activo al mes.`, basicExport: 'Exportar básico', reportLevelExport: 'Todos los datos - a nivel de informe', expenseLevelExport: 'Todos los datos - a nivel de gasto', - multipleTaxExport: 'Canadian Multiple Tax Export', + multipleTaxExport: 'Exportación canadiense de impuestos múltiples', exportInProgress: 'Exportación en curso', conciergeWillSend: 'Concierge te enviará el archivo en breve.', currentView: 'Vista actual', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index f2e27bb7de53..5c60372c38c0 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -10472,7 +10472,7 @@ Voici un *reçu test* pour vous montrer comment ça fonctionne :`, basicExport: 'Export basique', reportLevelExport: 'Toutes les données - niveau note de frais', expenseLevelExport: 'Toutes les données - niveau dépense', - multipleTaxExport: 'Canadian Multiple Tax Export', + multipleTaxExport: 'Export canadien à taxes multiples', exportInProgress: 'Export en cours', conciergeWillSend: 'Concierge vous enverra le fichier sous peu.', currentView: 'Vue actuelle', diff --git a/src/languages/it.ts b/src/languages/it.ts index 14e1eeef6a4d..c047e88d711d 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -10409,7 +10409,7 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`, basicExport: 'Esportazione di base', reportLevelExport: 'Tutti i dati - livello report', expenseLevelExport: 'Tutti i dati - livello spesa', - multipleTaxExport: 'Canadian Multiple Tax Export', + multipleTaxExport: 'Esportazione canadese con imposte multiple', exportInProgress: 'Esportazione in corso', conciergeWillSend: 'Concierge ti invierà il file a breve.', currentView: 'Vista corrente', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index a111fc4a5f54..63e453486994 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -10272,7 +10272,7 @@ ${reportName}`, basicExport: '基本エクスポート', reportLevelExport: 'すべてのデータ - レポートレベル', expenseLevelExport: 'すべてのデータ - 経費レベル', - multipleTaxExport: 'Canadian Multiple Tax Export', + multipleTaxExport: 'カナダの複数税エクスポート', exportInProgress: 'エクスポート処理中', conciergeWillSend: 'Conciergeがまもなくファイルを送信します。', currentView: '現在のビュー', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 11c9398423be..91f0544e73c0 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -10380,7 +10380,7 @@ Hier is een *proefbon* om je te laten zien hoe het werkt:`, basicExport: 'Standaardexport', reportLevelExport: 'Alle gegevens - rapportniveau', expenseLevelExport: 'Alle gegevens - uitgaveniveau', - multipleTaxExport: 'Canadian Multiple Tax Export', + multipleTaxExport: 'Canadese export met meerdere belastingen', exportInProgress: 'Export bezig', conciergeWillSend: 'Concierge stuurt je het bestand zo meteen.', currentView: 'Huidige weergave', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index a4ff24df734a..442db339ba8d 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -10349,7 +10349,7 @@ Oto *paragon testowy*, żeby pokazać Ci, jak to działa:`, basicExport: 'Podstawowy eksport', reportLevelExport: 'Wszystkie dane – poziom raportu', expenseLevelExport: 'Wszystkie dane – poziom wydatku', - multipleTaxExport: 'Canadian Multiple Tax Export', + multipleTaxExport: 'Kanadyjski eksport z wieloma podatkami', exportInProgress: 'Trwa eksport', conciergeWillSend: 'Concierge wkrótce wyśle Ci plik.', currentView: 'Bieżący widok', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index c5403d1fb4f5..b6031da2a7f4 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -10373,7 +10373,7 @@ Aqui está um *comprovante de teste* para mostrar como funciona:`, basicExport: 'Exportação básica', reportLevelExport: 'Todos os dados - nível de relatório', expenseLevelExport: 'Todos os dados - nível de despesa', - multipleTaxExport: 'Canadian Multiple Tax Export', + multipleTaxExport: 'Exportação canadense de múltiplos impostos', exportInProgress: 'Exportação em andamento', conciergeWillSend: 'O Concierge enviará o arquivo para você em breve.', currentView: 'Visualização atual', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 1006395f1414..7dd3b5781ab3 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -10024,7 +10024,7 @@ ${reportName}`, basicExport: '基本导出', reportLevelExport: '所有数据 - 报告级别', expenseLevelExport: '所有数据 - 报销级别', - multipleTaxExport: 'Canadian Multiple Tax Export', + multipleTaxExport: '加拿大多种税导出', exportInProgress: '导出进行中', conciergeWillSend: 'Concierge 将很快把文件发送给你。', currentView: '当前视图', diff --git a/src/libs/SearchQueryUtils.ts b/src/libs/SearchQueryUtils.ts index c1bc9876d0f8..d60c8395a5a6 100644 --- a/src/libs/SearchQueryUtils.ts +++ b/src/libs/SearchQueryUtils.ts @@ -56,6 +56,7 @@ import Onyx from 'react-native-onyx'; import type {SearchFullscreenNavigatorParamList} from './Navigation/types'; +import {getStandardExportTemplateDisplayName} from './AccountingUtils'; import {getBankAccountSearchLabel, isBankAccountPartiallySetup} from './BankAccountUtils'; import {getCardFeedsForDisplay} from './CardFeedUtils'; import {getCardDescription} from './CardUtils'; @@ -1744,13 +1745,8 @@ function getFilterDisplayValue({ return getPolicyNameWithFallback(filterValue, policies, reports); } if (filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO) { - if (filterValue === CONST.REPORT.EXPORT_OPTIONS.REPORT_LEVEL_EXPORT) { - return CONST.REPORT.EXPORT_OPTION_LABELS.REPORT_LEVEL_EXPORT; - } - if (filterValue === CONST.REPORT.EXPORT_OPTIONS.EXPENSE_LEVEL_EXPORT) { - return CONST.REPORT.EXPORT_OPTION_LABELS.EXPENSE_LEVEL_EXPORT; - } - return filterValue; + // A query can carry a standard template's ID, so display the label the backend records for it. Custom template names are returned as-is. + return getStandardExportTemplateDisplayName(filterValue); } return filterValue; } diff --git a/tests/unit/Search/SearchQueryUtilsTest.ts b/tests/unit/Search/SearchQueryUtilsTest.ts index 6acb01c38520..1c6f9c8a41ae 100644 --- a/tests/unit/Search/SearchQueryUtilsTest.ts +++ b/tests/unit/Search/SearchQueryUtilsTest.ts @@ -2787,6 +2787,39 @@ describe('SearchQueryUtils', () => { expect(result).toBe(CONST.REPORT.EXPORT_OPTION_LABELS.REPORT_LEVEL_EXPORT); }); + it('should display the label the backend records for the Canadian multiple tax export template', () => { + const result = getFilterDisplayValue({ + filterName: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, + filterValue: CONST.REPORT.EXPORT_OPTIONS.MULTIPLE_TAX_EXPORT, + personalDetails: {}, + reports: {}, + cardList: mockCardList, + cardFeeds: mockCardFeeds, + policies: mockPolicies, + currentUserAccountID, + translate: translateLocal, + }); + + expect(result).toBe(CONST.REPORT.EXPORT_OPTION_LABELS.MULTIPLE_TAX_EXPORT); + }); + + it('should return a custom export template name as-is', () => { + const customTemplateName = 'Custom Export Layout'; + const result = getFilterDisplayValue({ + filterName: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, + filterValue: customTemplateName, + personalDetails: {}, + reports: {}, + cardList: mockCardList, + cardFeeds: mockCardFeeds, + policies: mockPolicies, + currentUserAccountID, + translate: translateLocal, + }); + + expect(result).toBe(customTemplateName); + }); + it('should handle policyID filter by looking up policy name', () => { const policies: OnyxCollection = { [`${ONYXKEYS.COLLECTION.POLICY}abc123`]: {