Skip to content
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

Fix - Reports - Card filter page is empty when physical card is not activated #55900

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading