Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/hooks/useAdvancedSearchFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const typeFiltersKeys = {
CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED,
CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED,
// CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, // Temporarily hidden
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_TYPE,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN,
Expand All @@ -80,7 +80,7 @@ const typeFiltersKeys = {
CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED,
CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED,
// CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, // Temporarily hidden
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_TYPE,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN,
Expand Down Expand Up @@ -156,7 +156,7 @@ const typeFiltersKeys = {
CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED,
CONST.SEARCH.SYNTAX_FILTER_KEYS.PAID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED,
// CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO, // Temporarily hidden
CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
CONST.SEARCH.SYNTAX_FILTER_KEYS.TITLE,
],
],
Expand Down
30 changes: 0 additions & 30 deletions src/hooks/useExportedToAutocompleteList.ts

This file was deleted.

11 changes: 3 additions & 8 deletions src/hooks/useExportedToFilterOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ type UseExportedToFilterDataResult = {

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

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

const standardExportTemplates: string[] = [];
const customExportTemplates: string[] = [];
for (const template of combinedUniqueExportTemplates) {
const displayName = getStandardExportTemplateDisplayName(template.templateName);
const isStandardTemplate = displayName !== template.templateName;

if (isStandardTemplate) {
standardExportTemplates.push(displayName);
} else {
customExportTemplates.push(template.name ?? template.templateName);
}
}

customExportTemplates.sort((a, b) => localeCompare(a, b));

const connectedIntegrationNames = policyIDs && policyIDs.length === 0 ? new Set<string>() : getConnectedIntegrationNamesForPolicies(policies, policyIDs);

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

const exportedToFilterOptions = [...connectedIntegrationDisplayNames, ...customExportTemplates, ...standardExportTemplates];
const exportedToFilterOptions = [...connectedIntegrationDisplayNames, ...standardExportTemplates];

return {
exportedToFilterOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL: Record<string, string> = {

function SearchFiltersExportedToPage() {
const styles = useThemeStyles();
const {translate, localeCompare} = useLocalize();
const {translate} = useLocalize();
const StyleUtils = useStyleUtils();
const theme = useTheme();
const expensifyIcons = useMemoizedLazyExpensifyIcons(['XeroSquare', 'QBOSquare', 'NetSuiteSquare', 'IntacctSquare', 'QBDSquare', 'CertiniaSquare', 'Table']);
Expand Down Expand Up @@ -95,35 +95,27 @@ function SearchFiltersExportedToPage() {
}
const deduplicatedExportTemplates = Array.from(exportTemplatesByTemplateId.values());

const customExportTemplatePickerItems: SearchMultipleSelectionPickerItem[] = [];
const standardExportTemplatePickerItems: SearchMultipleSelectionPickerItem[] = [];

for (const template of deduplicatedExportTemplates) {
if (!template.templateName || integrationConnectionNamesSet.has(template.templateName)) {
continue;
}

if (!STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName]) {
continue;
}

const displayName = template.name ?? template.templateName ?? '';
const isStandardExportTemplate = !!STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName];
const filterValue = isStandardExportTemplate
? (STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName] ?? template.templateName)
: (template.name ?? template.templateName);
const pickerItem: SearchMultipleSelectionPickerItem = {
const filterValue = STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName] ?? template.templateName;
standardExportTemplatePickerItems.push({
name: displayName,
value: filterValue,
leftElement: tableIconForExportOption,
};

if (STANDARD_EXPORT_TEMPLATE_ID_TO_DISPLAY_LABEL[template.templateName]) {
standardExportTemplatePickerItems.push(pickerItem);
} else {
customExportTemplatePickerItems.push(pickerItem);
}
});
}

customExportTemplatePickerItems.sort((a, b) => localeCompare(a.name, b.name));

return [...connectedIntegrationPickerItems, ...customExportTemplatePickerItems, ...standardExportTemplatePickerItems];
return [...connectedIntegrationPickerItems, ...standardExportTemplatePickerItems];
})();

const initiallySelectedPickerItems: SearchMultipleSelectionPickerItem[] | undefined = (() => {
Expand Down
130 changes: 0 additions & 130 deletions tests/unit/hooks/useExportedToAutocompleteList.test.ts

This file was deleted.

4 changes: 2 additions & 2 deletions tests/unit/hooks/useExportedToFilterOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ describe('useExportedToFilterOptions', () => {
expect(result.current.connectedIntegrationNames).toContain(CONST.POLICY.CONNECTIONS.NAME.QBO);
});

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

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

expect(result.current.exportedToFilterOptions).toContain(customName);
expect(result.current.exportedToFilterOptions).not.toContain(customName);
});

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