Skip to content

Commit bbb6cbd

Browse files
authored
Merge pull request Expensify#84306 from samranahm/83710/remove-custom-template-from-exported-to
refactor: remove custom export templates from exported to options
2 parents d955410 + 2f2d6f3 commit bbb6cbd

6 files changed

Lines changed: 17 additions & 190 deletions

File tree

src/hooks/useAdvancedSearchFilters.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const typeFiltersKeys = {
5555
CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED,
5656
CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID,
5757
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED,
58-
// CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, // Temporarily hidden
58+
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
5959
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_TYPE,
6060
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID,
6161
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN,
@@ -80,7 +80,7 @@ const typeFiltersKeys = {
8080
CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED,
8181
CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID,
8282
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED,
83-
// CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, // Temporarily hidden
83+
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
8484
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_TYPE,
8585
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID,
8686
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN,
@@ -156,7 +156,7 @@ const typeFiltersKeys = {
156156
CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED,
157157
CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID,
158158
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED,
159-
// CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, // Temporarily hidden
159+
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
160160
CONST.SEARCH.SYNTAX_FILTER_KEYS.TITLE,
161161
],
162162
],

src/hooks/useExportedToAutocompleteList.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/hooks/useExportedToFilterOptions.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ type UseExportedToFilterDataResult = {
1717

1818
/**
1919
* Hook that prepares all data needed for the exported to search filter.
20-
* It collects export templates and all connected integrations to build the filter options.
20+
* It collects standard export templates and all connected integrations to build the filter options.
2121
* When currentSearchQueryJSON has policyID, options are scoped to those workspaces so form hydration and autocomplete stay consistent.
2222
*/
2323
export default function useExportedToFilterOptions(): UseExportedToFilterDataResult {
2424
const {currentSearchQueryJSON} = useSearchStateContext();
2525
const policyIDs = currentSearchQueryJSON?.policyID;
2626

27-
const {translate, localeCompare} = useLocalize();
27+
const {translate} = useLocalize();
2828
const [integrationsExportTemplates] = useOnyx(ONYXKEYS.NVP_INTEGRATION_SERVER_EXPORT_TEMPLATES);
2929
const [csvExportLayouts] = useOnyx(ONYXKEYS.NVP_CSV_EXPORT_LAYOUTS);
3030
const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
@@ -45,20 +45,15 @@ export default function useExportedToFilterOptions(): UseExportedToFilterDataRes
4545
const combinedUniqueExportTemplates = Array.from(uniqueExportTemplatesByName.values());
4646

4747
const standardExportTemplates: string[] = [];
48-
const customExportTemplates: string[] = [];
4948
for (const template of combinedUniqueExportTemplates) {
5049
const displayName = getStandardExportTemplateDisplayName(template.templateName);
5150
const isStandardTemplate = displayName !== template.templateName;
5251

5352
if (isStandardTemplate) {
5453
standardExportTemplates.push(displayName);
55-
} else {
56-
customExportTemplates.push(template.name ?? template.templateName);
5754
}
5855
}
5956

60-
customExportTemplates.sort((a, b) => localeCompare(a, b));
61-
6257
const connectedIntegrationNames = policyIDs && policyIDs.length === 0 ? new Set<string>() : getConnectedIntegrationNamesForPolicies(policies, policyIDs);
6358

6459
const displayNameToConnectionName = new Map<string, string>(
@@ -70,7 +65,7 @@ export default function useExportedToFilterOptions(): UseExportedToFilterDataRes
7065
return connectionName && connectedIntegrationNames.has(connectionName);
7166
});
7267

73-
const exportedToFilterOptions = [...connectedIntegrationDisplayNames, ...customExportTemplates, ...standardExportTemplates];
68+
const exportedToFilterOptions = [...connectedIntegrationDisplayNames, ...standardExportTemplates];
7469

7570
return {
7671
exportedToFilterOptions,

src/pages/Search/SearchAdvancedFiltersPage/SearchFiltersExportedToPage.tsx

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL: Record<string, string> = {
3030

3131
function SearchFiltersExportedToPage() {
3232
const styles = useThemeStyles();
33-
const {translate, localeCompare} = useLocalize();
33+
const {translate} = useLocalize();
3434
const StyleUtils = useStyleUtils();
3535
const theme = useTheme();
3636
const expensifyIcons = useMemoizedLazyExpensifyIcons(['XeroSquare', 'QBOSquare', 'NetSuiteSquare', 'IntacctSquare', 'QBDSquare', 'CertiniaSquare', 'Table']);
@@ -95,35 +95,27 @@ function SearchFiltersExportedToPage() {
9595
}
9696
const deduplicatedExportTemplates = Array.from(exportTemplatesByTemplateId.values());
9797

98-
const customExportTemplatePickerItems: SearchMultipleSelectionPickerItem[] = [];
9998
const standardExportTemplatePickerItems: SearchMultipleSelectionPickerItem[] = [];
10099

101100
for (const template of deduplicatedExportTemplates) {
102101
if (!template.templateName || integrationConnectionNamesSet.has(template.templateName)) {
103102
continue;
104103
}
105104

105+
if (!STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName]) {
106+
continue;
107+
}
108+
106109
const displayName = template.name ?? template.templateName ?? '';
107-
const isStandardExportTemplate = !!STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName];
108-
const filterValue = isStandardExportTemplate
109-
? (STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName] ?? template.templateName)
110-
: (template.name ?? template.templateName);
111-
const pickerItem: SearchMultipleSelectionPickerItem = {
110+
const filterValue = STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName] ?? template.templateName;
111+
standardExportTemplatePickerItems.push({
112112
name: displayName,
113113
value: filterValue,
114114
leftElement: tableIconForExportOption,
115-
};
116-
117-
if (STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName]) {
118-
standardExportTemplatePickerItems.push(pickerItem);
119-
} else {
120-
customExportTemplatePickerItems.push(pickerItem);
121-
}
115+
});
122116
}
123117

124-
customExportTemplatePickerItems.sort((a, b) => localeCompare(a.name, b.name));
125-
126-
return [...connectedIntegrationPickerItems, ...customExportTemplatePickerItems, ...standardExportTemplatePickerItems];
118+
return [...connectedIntegrationPickerItems, ...standardExportTemplatePickerItems];
127119
})();
128120

129121
const initiallySelectedPickerItems: SearchMultipleSelectionPickerItem[] | undefined = (() => {

tests/unit/hooks/useExportedToAutocompleteList.test.ts

Lines changed: 0 additions & 130 deletions
This file was deleted.

tests/unit/hooks/useExportedToFilterOptions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ describe('useExportedToFilterOptions', () => {
5959
expect(result.current.connectedIntegrationNames).toContain(CONST.POLICY.CONNECTIONS.NAME.QBO);
6060
});
6161

62-
it('includes custom template name in options when getExportTemplates returns custom template', () => {
62+
it('excludes custom template name from options when getExportTemplates returns custom template', () => {
6363
const customName = 'Export Layout';
6464
mockGetExportTemplates.mockReturnValue([{templateName: customName, name: customName} as ExportTemplate]);
6565

6666
const {result} = renderHook(() => useExportedToFilterOptions());
6767

68-
expect(result.current.exportedToFilterOptions).toContain(customName);
68+
expect(result.current.exportedToFilterOptions).not.toContain(customName);
6969
});
7070

7171
it('includes standard export label in options when getExportTemplates returns standard template', () => {

0 commit comments

Comments
 (0)