11import { filterCardsHiddenFromSearch } from '@selectors/Card' ;
2- import { emailSelector } from '@selectors/Session' ;
32import React , { useMemo } from 'react' ;
43import { View } from 'react-native' ;
54import type { ValueOf } from 'react-native-gesture-handler/lib/typescript/typeUtils' ;
@@ -14,22 +13,20 @@ import type {SearchAmountFilterKeys, SearchDateFilterKeys, SearchDatePreset, Sea
1413import SpacerView from '@components/SpacerView' ;
1514import Text from '@components/Text' ;
1615import useAdvancedSearchFilters from '@hooks/useAdvancedSearchFilters' ;
17- import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' ;
1816import useLocalize from '@hooks/useLocalize' ;
1917import useOnyx from '@hooks/useOnyx' ;
2018import useSingleExecution from '@hooks/useSingleExecution' ;
2119import useThemeStyles from '@hooks/useThemeStyles' ;
2220import useWaitForNavigation from '@hooks/useWaitForNavigation' ;
2321import type { WorkspaceListItem } from '@hooks/useWorkspaceList' ;
24- import useWorkspaceList from '@hooks/useWorkspaceList' ;
2522import { saveSearch } from '@libs/actions/Search' ;
2623import { createCardFeedKey , getCardFeedKey , getCardFeedNamesWithType , getWorkspaceCardFeedKey } from '@libs/CardFeedUtils' ;
2724import { getCardDescription } from '@libs/CardUtils' ;
2825import { convertToDisplayStringWithoutCurrency } from '@libs/CurrencyUtils' ;
2926import Navigation from '@libs/Navigation/Navigation' ;
3027import { createDisplayName } from '@libs/PersonalDetailsUtils' ;
3128import { getAllTaxRates , getCleanedTagName } from '@libs/PolicyUtils' ;
32- import { computeReportName } from '@libs/ReportNameUtils' ;
29+ import { getReportName } from '@libs/ReportNameUtils' ;
3330import {
3431 buildCannedSearchQuery ,
3532 buildQueryStringFromFilterFormValues ,
@@ -47,7 +44,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
4744import ROUTES from '@src/ROUTES' ;
4845import type { SearchAdvancedFiltersForm } from '@src/types/form' ;
4946import { AMOUNT_FILTER_KEYS , DATE_FILTER_KEYS } from '@src/types/form/SearchAdvancedFiltersForm' ;
50- import type { CardList , PersonalDetailsList , Policy , Report , WorkspaceCardsList } from '@src/types/onyx' ;
47+ import type { CardList , PersonalDetailsList , Policy , Report , ReportAttributesDerivedValue , WorkspaceCardsList } from '@src/types/onyx' ;
5148import type { SearchDataTypes } from '@src/types/onyx/SearchResults' ;
5249import { getEmptyObject } from '@src/types/utils/EmptyObject' ;
5350
@@ -554,9 +551,14 @@ function getFilterExpenseDisplayTitle(filters: Partial<SearchAdvancedFiltersForm
554551 : undefined ;
555552}
556553
557- function getFilterInDisplayTitle ( filters : Partial < SearchAdvancedFiltersForm > , _ : LocaleContextProps [ 'translate' ] , reports : OnyxCollection < Report > | undefined , currentUserAccountID : number ) {
554+ function getFilterInDisplayTitle (
555+ filters : Partial < SearchAdvancedFiltersForm > ,
556+ _ : LocaleContextProps [ 'translate' ] ,
557+ reports : OnyxCollection < Report > ,
558+ reportAttributes : ReportAttributesDerivedValue [ 'reports' ] ,
559+ ) {
558560 return filters . in
559- ?. map ( ( id ) => computeReportName ( reports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ id } ` ] , reports , undefined , undefined , undefined , undefined , undefined , currentUserAccountID ) )
561+ ?. map ( ( id ) => getReportName ( reports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ id } ` ] , reportAttributes ) )
560562 ?. filter ( Boolean )
561563 ?. join ( ', ' ) ;
562564}
@@ -571,23 +573,13 @@ function AdvancedSearchFilters() {
571573 const [ searchAdvancedFilters = getEmptyObject < SearchAdvancedFiltersForm > ( ) ] = useOnyx ( ONYXKEYS . FORMS . SEARCH_ADVANCED_FILTERS_FORM , { canBeMissing : true } ) ;
572574 const [ searchCards ] = useOnyx ( ONYXKEYS . DERIVED . NON_PERSONAL_AND_WORKSPACE_CARD_LIST , { canBeMissing : true , selector : filterCardsHiddenFromSearch } ) ;
573575 const personalDetails = usePersonalDetails ( ) ;
576+ const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { canBeMissing : true } ) ;
574577
575578 const [ policies = getEmptyObject < NonNullable < OnyxCollection < Policy > > > ( ) ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { canBeMissing : false } ) ;
576- const [ currentUserLogin ] = useOnyx ( ONYXKEYS . SESSION , { canBeMissing : false , selector : emailSelector } ) ;
577- const { accountID : currentUserAccountID } = useCurrentUserPersonalDetails ( ) ;
578579
579580 const taxRates = getAllTaxRates ( policies ) ;
580581
581- const { sections : workspaces } = useWorkspaceList ( {
582- policies,
583- currentUserLogin,
584- shouldShowPendingDeletePolicy : false ,
585- selectedPolicyIDs : undefined ,
586- searchTerm : '' ,
587- localeCompare,
588- } ) ;
589-
590- const { currentType, typeFiltersKeys} = useAdvancedSearchFilters ( ) ;
582+ const { currentType, typeFiltersKeys, workspaces} = useAdvancedSearchFilters ( ) ;
591583
592584 const queryString = useMemo ( ( ) => {
593585 const currentQueryJSON = getCurrentSearchQueryJSON ( ) ;
@@ -641,7 +633,7 @@ function AdvancedSearchFilters() {
641633 ) {
642634 filterTitle = baseFilterConfig [ key ] . getTitle ( searchAdvancedFilters [ key ] ?? [ ] , personalDetails , formatPhoneNumber ) ;
643635 } else if ( key === CONST . SEARCH . SYNTAX_FILTER_KEYS . IN ) {
644- filterTitle = baseFilterConfig [ key ] . getTitle ( searchAdvancedFilters , translate , reports , currentUserAccountID ) ;
636+ filterTitle = baseFilterConfig [ key ] . getTitle ( searchAdvancedFilters , translate , reports , reportAttributes ?. reports ?? { } ) ;
645637 } else if ( key === CONST . SEARCH . SYNTAX_FILTER_KEYS . POLICY_ID ) {
646638 const workspacesData = workspaces . flatMap ( ( value ) => value . data ) ;
647639 filterTitle = baseFilterConfig [ key ] . getTitle ( searchAdvancedFilters , workspacesData ) ;
0 commit comments