Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
970988e
Update search parsers to support exportedTo filter
samranahm Jan 31, 2026
595dfcf
Add exportedTo to advanced search filters hook
samranahm Jan 31, 2026
fa6b1d2
Update navigation and routing for exportedTo filter
samranahm Jan 31, 2026
0a3ea18
Add exportedTo filter types and form definitions
samranahm Jan 31, 2026
eaa85d2
Implement exportedTo filter utilities and logic
samranahm Jan 31, 2026
24e1123
Add exportedTo filter UI components
samranahm Jan 31, 2026
7296c49
resolve merge conflicts
samranahm Jan 31, 2026
f9b6cb5
refector SearchFiltersExportedToPage
samranahm Feb 1, 2026
df25faf
add CertiniaSquare icon at missing locations
samranahm Feb 1, 2026
1de8814
add certinia in type Connections
samranahm Feb 1, 2026
f08cb11
refactor exported-to filter to use map keys for consistent value mapping
samranahm Feb 1, 2026
889e600
add exported-to-search-value in AccountingUtils
samranahm Feb 1, 2026
7ed3fee
add certinia in const
samranahm Feb 1, 2026
21ee4ae
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 1, 2026
1bac4eb
fix: lint
samranahm Feb 1, 2026
dc41412
remove fill prope from icon component
samranahm Feb 1, 2026
645352e
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 3, 2026
ecd5a94
Implement review feedback
samranahm Feb 3, 2026
7f92b2a
Fix failing checks
samranahm Feb 3, 2026
9a58eff
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 4, 2026
ed4ed85
Merge remote-tracking branch 'upstream' into 80005/Add-exported-to-fi…
samranahm Feb 4, 2026
661e030
Implement code review suggestions
samranahm Feb 4, 2026
4956829
fix failing checks
samranahm Feb 4, 2026
b568663
remove clip-path element from certinia-icon-square
samranahm Feb 5, 2026
708e359
Merge branch 'Expensify:main' into 80005/Add-exported-to-filter
samranahm Feb 6, 2026
278157a
update icons size and remove getPredefinedConnectionNamesForSearch he…
samranahm Feb 9, 2026
909169a
Add Standard exported templates in SearchAutocomplete List and Input
samranahm Feb 9, 2026
92bde72
Add unit test
samranahm Feb 9, 2026
36b8610
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 10, 2026
65277c1
lint
samranahm Feb 10, 2026
116bc94
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 11, 2026
cb66687
Add hook for exported-to autocomplete list and refactor related compo…
samranahm Feb 11, 2026
22d9039
use existing CONNECTIONS.NAME_USER_FRIENDLY
samranahm Feb 11, 2026
9e4e669
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 13, 2026
1133add
Add connected accounting integration filtering to export to options
samranahm Feb 13, 2026
1f6680e
add getConnectedIntegrationNamesForPolicies
samranahm Feb 14, 2026
9b004e6
add standard export templete in build filter form
samranahm Feb 14, 2026
02f805b
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 16, 2026
8122fe3
Remove redundant useMemo/useCallback and let React Compiler handle me…
samranahm Feb 16, 2026
e1fe0ab
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 18, 2026
57ccbdf
create useExportedToFilterOptions hook for Exported To filter options
samranahm Feb 18, 2026
1fa0728
lint
samranahm Feb 18, 2026
3b2c174
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 20, 2026
2d4dd96
fix falin
samranahm Feb 23, 2026
0172615
remove canBeMissing to fix typecheck
samranahm Feb 23, 2026
d1b10f3
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 24, 2026
5e1f3a3
Add mock for useExportedToFilterOptions hook
samranahm Feb 24, 2026
3c869a5
Add unit test
samranahm Feb 25, 2026
a526351
checl policyIDs from useSearchContext
samranahm Feb 25, 2026
5d69c5f
Merge remote-tracking branch 'upstream' into 80005/Add-exported-to-fi…
samranahm Feb 25, 2026
24cc0c2
update useExportedToFilterOptions hook to useSearchStateContext
samranahm Feb 25, 2026
1dc8f4e
Update route to use user-friendly keys
samranahm Feb 25, 2026
0927353
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm Feb 25, 2026
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
2 changes: 1 addition & 1 deletion assets/images/integrationicons/certinia-icon-square.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3430,6 +3430,7 @@ const CONST = {
XERO: 'xero',
NETSUITE: 'netsuite',
SAGE_INTACCT: 'intacct',
CERTINIA: 'certinia',
},
SUPPORTED_ONLY_ON_OLDDOT: {
FINANCIALFORCE: 'financialForce',
Expand All @@ -3443,6 +3444,7 @@ const CONST = {
NETSUITE: 'netsuite',
SAGE_INTACCT: 'sage-intacct',
QBD: 'quickbooks-desktop',
CERTINIA: 'certinia',
},
NAME_USER_FRIENDLY: {
netsuite: 'NetSuite',
Expand All @@ -3451,13 +3453,17 @@ const CONST = {
xero: 'Xero',
intacct: 'Sage Intacct',
financialForce: 'FinancialForce',
certinia: 'Certinia',
billCom: 'Bill.com',
zenefits: 'Zenefits',
sap: 'SAP',
oracle: 'Oracle',
microsoftDynamics: 'Microsoft Dynamics',
other: 'Other',
},
get EXPORTED_TO_INTEGRATION_DISPLAY_NAMES(): string[] {
return Object.values(this.NAME).map((name) => this.NAME_USER_FRIENDLY[name as keyof typeof this.NAME_USER_FRIENDLY]);
},
CORPORATE: ['quickbooksDesktop', 'netsuite', 'intacct', 'oracle', 'sap', 'microsoftDynamics', 'other'],
AUTH_HELP_LINKS: {
intacct:
Expand Down Expand Up @@ -7464,6 +7470,7 @@ const CONST = {
ATTENDEE: 'attendee',
IS: 'is',
REPORT_FIELD: 'reportField',
EXPORTED_TO: 'exportedTo',
},
REPORT_FIELD: {
// All report fields start with this, so use this to check if a search key is a report field
Expand Down Expand Up @@ -7530,6 +7537,7 @@ const CONST = {
ATTENDEE: 'attendee',
IS: 'is',
REPORT_FIELD: 'report-field',
EXPORTED_TO: 'exported-to',
COLUMNS: 'columns',
LIMIT: 'limit',
},
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const SCREENS = {
ADVANCED_FILTERS_APPROVED_RHP: 'Search_Advanced_Filters_Approved_RHP',
ADVANCED_FILTERS_PAID_RHP: 'Search_Advanced_Filters_Paid_RHP',
ADVANCED_FILTERS_EXPORTED_RHP: 'Search_Advanced_Filters_Exported_RHP',
ADVANCED_FILTERS_EXPORTED_TO_RHP: 'Search_Advanced_Filters_Exported_To_RHP',
ADVANCED_FILTERS_POSTED_RHP: 'Search_Advanced_Filters_Posted_RHP',
ADVANCED_FILTERS_WITHDRAWN_RHP: 'Search_Advanced_Filters_Withdrawn_RHP',
ADVANCED_FILTERS_CURRENCY_RHP: 'Search_Advanced_Filters_Currency_RHP',
Expand Down
2 changes: 1 addition & 1 deletion src/components/ImportedFromAccountingSoftware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function ImportedFromAccountingSoftware({policyID, currentConnectionName, transl
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const {environmentURL} = useEnvironment();
const expensifyIcons = useMemoizedLazyExpensifyIcons(['XeroSquare', 'QBOSquare', 'NetSuiteSquare', 'IntacctSquare', 'QBDSquare']);
const expensifyIcons = useMemoizedLazyExpensifyIcons(['XeroSquare', 'QBOSquare', 'NetSuiteSquare', 'IntacctSquare', 'QBDSquare', 'CertiniaSquare']);
const icon = getIntegrationIcon(connectedIntegration, expensifyIcons);

if (!customTagName && shouldShow) {
Expand Down
1 change: 1 addition & 0 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
'NetSuiteSquare',
'IntacctSquare',
'QBDSquare',
'CertiniaSquare',
'Feed',
'Close',
'Location',
Expand Down Expand Up @@ -1764,7 +1765,7 @@
}
return option;
});
}, [originalSelectedTransactionsOptions, showDeleteModal, dismissedRejectUseExplanation]);

Check warning on line 1768 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useMemo has missing dependencies: 'isDelegateAccessRestricted' and 'showDelegateNoAccessModal'. Either include them or remove the dependency array

Check warning on line 1768 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useMemo has missing dependencies: 'isDelegateAccessRestricted' and 'showDelegateNoAccessModal'. Either include them or remove the dependency array

const shouldShowSelectedTransactionsButton = !!selectedTransactionsOptions.length && !transactionThreadReportID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function ExportWithDropdownMenu({
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {showConfirmModal} = useConfirmModal();
const [exportMethods] = useOnyx(ONYXKEYS.LAST_EXPORT_METHOD);
const expensifyIcons = useMemoizedLazyExpensifyIcons(['XeroSquare', 'QBOSquare', 'NetSuiteSquare', 'IntacctSquare', 'QBDSquare']);
const expensifyIcons = useMemoizedLazyExpensifyIcons(['XeroSquare', 'QBOSquare', 'NetSuiteSquare', 'IntacctSquare', 'QBDSquare', 'CertiniaSquare']);

const iconToDisplay = getIntegrationIcon(connectionName, expensifyIcons);
const canBeExported = canBeExportedUtils(report);
Expand Down
14 changes: 13 additions & 1 deletion src/components/Search/SearchAutocompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import TextInput from '@components/TextInput';
import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';
import {useCurrencyListState} from '@hooks/useCurrencyList';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useExportedToFilterOptions from '@hooks/useExportedToFilterOptions';
import useFocusAfterNav from '@hooks/useFocusAfterNav';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
Expand Down Expand Up @@ -115,6 +116,9 @@ function SearchAutocompleteInput({
const emailList = Object.keys(loginList ?? {});
const emailListSharedValue = useSharedValue(emailList);

const {exportedToFilterOptions} = useExportedToFilterOptions();
const exportedToSharedValue = useSharedValue(exportedToFilterOptions);

const offlineMessage: string = isOffline && shouldShowOfflineMessage ? `${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}` : '';

const defaultBorderColor = theme.border;
Expand Down Expand Up @@ -164,11 +168,19 @@ function SearchAutocompleteInput({
});
}, [tagSharedValue, tagAutocompleteList]);

useEffect(() => {
scheduleOnLiveMarkdownRuntime(() => {
'worklet';

exportedToSharedValue.set(exportedToFilterOptions);
});
}, [exportedToSharedValue, exportedToFilterOptions]);

const currentUserDisplayName = currentUserPersonalDetails.displayName ?? '';
const parser = (input: string) => {
'worklet';

return parseForLiveMarkdown(input, currentUserDisplayName, substitutionMap, emailListSharedValue, currencySharedValue, categorySharedValue, tagSharedValue);
return parseForLiveMarkdown(input, currentUserDisplayName, substitutionMap, emailListSharedValue, currencySharedValue, categorySharedValue, tagSharedValue, exportedToSharedValue);
};

const clearInput = () => {
Expand Down
16 changes: 16 additions & 0 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import {useCurrencyListState} from '@hooks/useCurrencyList';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDebounce from '@hooks/useDebounce';
import useExportedToFilterOptions from '@hooks/useExportedToFilterOptions';
import useFeedKeysWithAssignedCards from '@hooks/useFeedKeysWithAssignedCards';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -351,6 +352,7 @@
const [allRecentTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS);
const tagAutocompleteList = getAutocompleteTags(allPoliciesTags);
const recentTagsAutocompleteList = getAutocompleteRecentTags(allRecentTags);
const {exportedToFilterOptions} = useExportedToFilterOptions();

const [autocompleteParsedQuery, autocompleteQueryWithoutFilters] = (() => {
const queryWithoutFilters = getQueryWithoutFilters(autocompleteQueryValue);
Expand Down Expand Up @@ -643,6 +645,20 @@

return filteredIsValues.map((isValue) => ({filterKey: CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.IS, text: isValue}));
}
case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO: {
const filteredExportedTo = exportedToFilterOptions
.filter((value) => {
const lowerValue = value.toLowerCase();
return lowerValue.includes(autocompleteValue.toLowerCase()) && !alreadyAutocompletedKeys.has(lowerValue);
Comment thread
samranahm marked this conversation as resolved.
Resolved
})
.sort()
.slice(0, 10);
return filteredExportedTo.map((value) => ({
filterKey: CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.EXPORTED_TO,
text: value,
mapKey: CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTED_TO,
}));
}
case CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.SUBMITTED:
case CONST.SEARCH.SYNTAX_FILTER_KEYS.APPROVED:
Expand Down Expand Up @@ -884,7 +900,7 @@
flatIndex++;
}
}
}, [areOptionsInitialized, firstRecentReportKey, shouldUseNarrowLayout]);

Check warning on line 903 in src/components/Search/SearchAutocompleteList.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useEffect has a missing dependency: 'sections'. Either include it or remove the dependency array

Check warning on line 903 in src/components/Search/SearchAutocompleteList.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useEffect has a missing dependency: 'sections'. Either include it or remove the dependency array

useEffect(() => {
const targetText = autocompleteQueryValue;
Expand Down
5 changes: 4 additions & 1 deletion src/components/Search/SearchMultipleSelectionPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SearchFilterPageFooterButtons from './SearchFilterPageFooterButtons';
type SearchMultipleSelectionPickerItem = {
name: string;
value: string | string[];
leftElement?: React.ReactNode;
};

type SearchMultipleSelectionPickerProps = {
Expand Down Expand Up @@ -40,6 +41,7 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItems, pickerTit
keyForList: item.name,
isSelected: true,
value: item.value,
leftElement: item.leftElement,
}));

const remainingItemsSection = items
Expand All @@ -53,6 +55,7 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItems, pickerTit
keyForList: item.name,
isSelected: false,
value: item.value,
leftElement: item.leftElement,
}));

const noResultsFound = !selectedItemsSection.length && !remainingItemsSection.length;
Expand All @@ -78,7 +81,7 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItems, pickerTit
if (item.isSelected) {
setSelectedItems(selectedItems?.filter((selectedItem) => selectedItem.name !== item.keyForList));
} else {
setSelectedItems([...(selectedItems ?? []), {name: item.text, value: item.value}]);
setSelectedItems([...(selectedItems ?? []), {name: item.text, value: item.value, leftElement: item.leftElement}]);
}
};

Expand Down
3 changes: 3 additions & 0 deletions src/hooks/useAdvancedSearchFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +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,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_TYPE,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN,
Expand All @@ -79,6 +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,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_TYPE,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_ID,
CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN,
Expand Down Expand Up @@ -154,6 +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,
CONST.SEARCH.SYNTAX_FILTER_KEYS.TITLE,
],
],
Expand Down
30 changes: 30 additions & 0 deletions src/hooks/useExportedToAutocompleteList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {useMemo} from 'react';
import {getStandardExportTemplateDisplayName} from '@libs/AccountingUtils';
import {getExportTemplates} from '@libs/actions/Search';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import useLocalize from './useLocalize';
import useOnyx from './useOnyx';

/**
* Hook that returns the list of export template names for the "exported-to:" search autocomplete.
* Combines predefined integration names EXPORTED_TO_INTEGRATION_DISPLAY_NAMES with custom export template names.
*/
export default function useExportedToAutocompleteList(): string[] {
Comment thread
samranahm marked this conversation as resolved.
Resolved
const {translate} = useLocalize();
const [integrationsExportTemplates] = useOnyx(ONYXKEYS.NVP_INTEGRATION_SERVER_EXPORT_TEMPLATES);
const [csvExportLayouts] = useOnyx(ONYXKEYS.NVP_CSV_EXPORT_LAYOUTS);

return useMemo(() => {
const exportTemplates = getExportTemplates(integrationsExportTemplates ?? [], csvExportLayouts ?? {}, translate, undefined, true);
const customNames = exportTemplates.flatMap((template) => {
const templateDisplayName = getStandardExportTemplateDisplayName(template.templateName);
if (templateDisplayName !== template.templateName) {
return [templateDisplayName];
}
return [template.templateName].filter(Boolean);
});

return Array.from(new Set([...CONST.POLICY.CONNECTIONS.EXPORTED_TO_INTEGRATION_DISPLAY_NAMES, ...customNames]));
}, [integrationsExportTemplates, csvExportLayouts, translate]);
}
80 changes: 80 additions & 0 deletions src/hooks/useExportedToFilterOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import {useSearchStateContext} from '@components/Search/SearchContext';
import {getStandardExportTemplateDisplayName} from '@libs/AccountingUtils';
import {getExportTemplates} from '@libs/actions/Search';
import {getConnectedIntegrationNamesForPolicies} from '@libs/PolicyUtils';
import {getAllPolicyValues} from '@libs/SearchQueryUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {ExportTemplate} from '@src/types/onyx';
import useLocalize from './useLocalize';
import useOnyx from './useOnyx';

type UseExportedToFilterDataResult = {
exportedToFilterOptions: string[];
combinedUniqueExportTemplates: ExportTemplate[];
connectedIntegrationNames: Set<string>;
};

/**
* 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.
* When currentSearchQueryJSON has policyID, options are scoped to those workspaces so form hydration and autocomplete stay consistent.
*/
export default function useExportedToFilterOptions(): UseExportedToFilterDataResult {
Comment thread
samranahm marked this conversation as resolved.
Resolved
const {currentSearchQueryJSON} = useSearchStateContext();
const policyIDs = currentSearchQueryJSON?.policyID;

const {translate, localeCompare} = useLocalize();
const [integrationsExportTemplates] = useOnyx(ONYXKEYS.NVP_INTEGRATION_SERVER_EXPORT_TEMPLATES);
const [csvExportLayouts] = useOnyx(ONYXKEYS.NVP_CSV_EXPORT_LAYOUTS);
const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);

// When search is scoped to workspaces, use only those policies otherwise use all.
const policiesToUse = policyIDs !== undefined ? getAllPolicyValues(policyIDs, ONYXKEYS.COLLECTION.POLICY, policies) : Object.values(policies ?? {});
const policyLevelExportTemplates = policiesToUse.flatMap((policy) => getExportTemplates([], {}, translate, policy, false));
const accountLevelExportTemplates = getExportTemplates(integrationsExportTemplates ?? [], csvExportLayouts ?? {}, translate, undefined, true);
const combinedExportTemplates = [...accountLevelExportTemplates, ...policyLevelExportTemplates];
Comment thread
samranahm marked this conversation as resolved.
Resolved

const uniqueExportTemplatesByName = new Map<string, ExportTemplate>();
for (const template of combinedExportTemplates) {
if (!uniqueExportTemplatesByName.has(template.templateName)) {
uniqueExportTemplatesByName.set(template.templateName, template);
}
}

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>(
Object.entries(CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY).map(([connectionName, displayName]) => [displayName, connectionName]),
);

const connectedIntegrationDisplayNames = CONST.POLICY.CONNECTIONS.EXPORTED_TO_INTEGRATION_DISPLAY_NAMES.filter((displayName) => {
const connectionName = displayNameToConnectionName.get(displayName);
return connectionName && connectedIntegrationNames.has(connectionName);
});

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

return {
exportedToFilterOptions,
combinedUniqueExportTemplates,
connectedIntegrationNames,
};
}
4 changes: 3 additions & 1 deletion src/hooks/useFilterFormValues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type {SearchAdvancedFiltersForm} from '@src/types/form';
import {getEmptyObject} from '@src/types/utils/EmptyObject';
import {useCurrencyListState} from './useCurrencyList';
import useExportedToFilterOptions from './useExportedToFilterOptions';
import useOnyx from './useOnyx';

const useFilterFormValues = (queryJSON?: SearchQueryJSON) => {
Expand All @@ -25,9 +26,10 @@ const useFilterFormValues = (queryJSON?: SearchQueryJSON) => {
// Helps to avoid unnecessary recalculations when user open report details screen. React Compiler does not provide same result.
const taxRates = useMemo(() => getAllTaxRates(policies), [policies]);
const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds ?? CONST.EMPTY_OBJECT, userCardList), [workspaceCardFeeds, userCardList]);
const {exportedToFilterOptions} = useExportedToFilterOptions();

const formValues = queryJSON
? buildFilterFormValuesFromQuery(queryJSON, policyCategories, policyTagsLists, currencyList, personalDetails, allCards, allReports, taxRates)
? buildFilterFormValuesFromQuery(queryJSON, policyCategories, policyTagsLists, currencyList, personalDetails, allCards, allReports, taxRates, exportedToFilterOptions)
Comment thread
samranahm marked this conversation as resolved.
Resolved
: getEmptyObject<Partial<SearchAdvancedFiltersForm>>();

return formValues;
Expand Down
Loading
Loading