Skip to content

Commit

Permalink
Merge pull request #55900 from FitseTLT/fix-card-search-filter-appear…
Browse files Browse the repository at this point in the history
…ing-without-active-cards
  • Loading branch information
francoisl authored Jan 31, 2025
2 parents fcb0605 + 7317bc5 commit 9689e56
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/libs/CardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,20 @@ function isCardHiddenFromSearch(card: Card) {
return !card?.nameValuePairs?.isVirtual && CONST.EXPENSIFY_CARD.HIDDEN_FROM_SEARCH_STATES.includes(card.state ?? 0);
}

function mergeCardListWithWorkspaceFeeds(workspaceFeeds: Record<string, WorkspaceCardsList | undefined>, cardList = allCards) {
const feedCards: CardList = {...cardList};
function mergeCardListWithWorkspaceFeeds(workspaceFeeds: Record<string, WorkspaceCardsList | undefined>, cardList = allCards, shouldExcludeCardHiddenFromSearch = false) {
const feedCards: CardList = {};
Object.keys(cardList).forEach((cardKey) => {
const card = cardList[cardKey];
if (shouldExcludeCardHiddenFromSearch && isCardHiddenFromSearch(card)) {
return;
}

feedCards[cardKey] = card;
});

Object.values(workspaceFeeds ?? {}).forEach((currentCardFeed) => {
Object.values(currentCardFeed ?? {}).forEach((card) => {
if (!isCard(card)) {
if (!isCard(card) || (shouldExcludeCardHiddenFromSearch && isCardHiddenFromSearch(card))) {
return;
}
feedCards[card.cardID] = card;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Search/AdvancedSearchFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function AdvancedSearchFilters() {
const policyID = searchAdvancedFilters.policyID;
const [userCardList = {}] = useOnyx(ONYXKEYS.CARD_LIST);
const [workspaceCardFeeds = {}] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST);
const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds, userCardList), [userCardList, workspaceCardFeeds]);
const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds, userCardList, true), [userCardList, workspaceCardFeeds]);
const taxRates = getAllTaxRates();
const personalDetails = usePersonalDetails();

Expand Down

0 comments on commit 9689e56

Please sign in to comment.