diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 486fce3eebef..d58646427545 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -527,6 +527,7 @@ function Search({ queryJSON, isActionLoadingSet, cardFeeds, + cardList: nonPersonalAndWorkspaceCards, isOffline, allTransactionViolations: violations, customCardNames, @@ -562,6 +563,7 @@ function Search({ email, isActionLoadingSet, cardFeeds, + nonPersonalAndWorkspaceCards, policies, bankAccountList, violations, diff --git a/src/hooks/useSearchSections.ts b/src/hooks/useSearchSections.ts index 7c1f1d012377..a8c8c70b8d5a 100644 --- a/src/hooks/useSearchSections.ts +++ b/src/hooks/useSearchSections.ts @@ -31,6 +31,7 @@ function useSearchSections(): UseSearchSectionsResult { }); const [cardFeeds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER); + const [nonPersonalAndWorkspaceCards] = useOnyx(ONYXKEYS.DERIVED.NON_PERSONAL_AND_WORKSPACE_CARD_LIST); const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const [allReportMetadata] = useOnyx(ONYXKEYS.COLLECTION.REPORT_METADATA); @@ -61,6 +62,7 @@ function useSearchSections(): UseSearchSectionsResult { archivedReportsIDList: archivedReportsIdSet, isActionLoadingSet, cardFeeds, + cardList: nonPersonalAndWorkspaceCards, allReportMetadata, conciergeReportID, reportAttributesDerivedValue, diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 223fa6d726d7..ca565c4599a6 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -592,6 +592,7 @@ type GetSectionsParams = { isActionLoadingSet?: ReadonlySet; isOffline?: boolean; cardFeeds?: OnyxCollection; + cardList?: OnyxEntry; customCardNames?: Record; allTransactionViolations?: OnyxCollection; visibleReportActionsData?: OnyxTypes.VisibleReportActionsDerivedValue; @@ -3085,6 +3086,7 @@ function getCardSections( translate: LocalizedTranslate, cardFeeds?: OnyxCollection, customCardNames?: Record, + cardList?: OnyxEntry, ): [TransactionCardGroupListItemType[], number, boolean] { const cardSections: Record = {}; const cardDescriptionByCardID = new Map(); @@ -3128,7 +3130,18 @@ function getCardSections( ...personalDetails, ...cardGroup, formattedCardName, - formattedFeedName: getFeedNameForDisplay(translate, cardGroup.bank as OnyxTypes.CompanyCardFeed, cardFeeds, undefined, true, cardGroup?.feedCountry), + formattedFeedName: getFeedNameForDisplay( + translate, + cardGroup.bank as OnyxTypes.CompanyCardFeed, + cardFeeds, + cardList?.[cardGroup.cardID]?.fundID + ? cardFeeds?.[`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${cardList[cardGroup.cardID].fundID}`]?.settings?.companyCardNicknames?.[ + cardGroup.bank as OnyxTypes.CompanyCardFeed + ] + : undefined, + true, + cardGroup?.feedCountry, + ), keyForList: key, }; } @@ -3472,6 +3485,7 @@ function getSections({ isActionLoadingSet, isOffline, cardFeeds, + cardList, customCardNames, allTransactionViolations, visibleReportActionsData, @@ -3518,7 +3532,7 @@ function getSections({ case CONST.SEARCH.GROUP_BY.FROM: return getMemberSections(data, queryJSON, formatPhoneNumber); case CONST.SEARCH.GROUP_BY.CARD: - return getCardSections(data, queryJSON, translate, cardFeeds, customCardNames); + return getCardSections(data, queryJSON, translate, cardFeeds, customCardNames, cardList); case CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID: return getWithdrawalIDSections(data, queryJSON); case CONST.SEARCH.GROUP_BY.CATEGORY: