Repository navigation
feat: Add exported-to filter in search filters
#81077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JS00001
merged 53 commits into
Expensify:main
from
samranahm:80005/Add-exported-to-filter
Feb 26, 2026
Merged
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 595dfcf
Add exportedTo to advanced search filters hook
samranahm fa6b1d2
Update navigation and routing for exportedTo filter
samranahm 0a3ea18
Add exportedTo filter types and form definitions
samranahm eaa85d2
Implement exportedTo filter utilities and logic
samranahm 24e1123
Add exportedTo filter UI components
samranahm 7296c49
resolve merge conflicts
samranahm f9b6cb5
refector SearchFiltersExportedToPage
samranahm df25faf
add CertiniaSquare icon at missing locations
samranahm 1de8814
add certinia in type Connections
samranahm f08cb11
refactor exported-to filter to use map keys for consistent value mapping
samranahm 889e600
add exported-to-search-value in AccountingUtils
samranahm 7ed3fee
add certinia in const
samranahm 21ee4ae
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm 1bac4eb
fix: lint
samranahm dc41412
remove fill prope from icon component
samranahm 645352e
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm ecd5a94
Implement review feedback
samranahm 7f92b2a
Fix failing checks
samranahm 9a58eff
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm ed4ed85
Merge remote-tracking branch 'upstream' into 80005/Add-exported-to-fi…
samranahm 661e030
Implement code review suggestions
samranahm 4956829
fix failing checks
samranahm b568663
remove clip-path element from certinia-icon-square
samranahm 708e359
Merge branch 'Expensify:main' into 80005/Add-exported-to-filter
samranahm 278157a
update icons size and remove getPredefinedConnectionNamesForSearch he…
samranahm 909169a
Add Standard exported templates in SearchAutocomplete List and Input
samranahm 92bde72
Add unit test
samranahm 36b8610
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm 65277c1
lint
samranahm 116bc94
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm cb66687
Add hook for exported-to autocomplete list and refactor related compo…
samranahm 22d9039
use existing CONNECTIONS.NAME_USER_FRIENDLY
samranahm 9e4e669
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm 1133add
Add connected accounting integration filtering to export to options
samranahm 1f6680e
add getConnectedIntegrationNamesForPolicies
samranahm 9b004e6
add standard export templete in build filter form
samranahm 02f805b
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm 8122fe3
Remove redundant useMemo/useCallback and let React Compiler handle me…
samranahm e1fe0ab
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm 57ccbdf
create useExportedToFilterOptions hook for Exported To filter options
samranahm 1fa0728
lint
samranahm 3b2c174
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm 2d4dd96
fix falin
samranahm 0172615
remove canBeMissing to fix typecheck
samranahm d1b10f3
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm 5e1f3a3
Add mock for useExportedToFilterOptions hook
samranahm 3c869a5
Add unit test
samranahm a526351
checl policyIDs from useSearchContext
samranahm 5d69c5f
Merge remote-tracking branch 'upstream' into 80005/Add-exported-to-fi…
samranahm 24cc0c2
update useExportedToFilterOptions hook to useSearchStateContext
samranahm 1dc8f4e
Update route to use user-friendly keys
samranahm 0927353
Merge remote-tracking branch 'upstream/main' into 80005/Add-exported-…
samranahm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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[] { | ||
|
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]); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { | ||
|
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]; | ||
|
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, | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.