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 logic of admin issued virtual card #45480

Merged
merged 1 commit into from
Jul 16, 2024
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
4 changes: 2 additions & 2 deletions src/pages/settings/Wallet/ExpensifyCardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ function ExpensifyCardPage({
const styles = useThemeStyles();
const {isOffline} = useNetwork();
const {translate} = useLocalize();
const shouldDisplayCardDomain = !cardList?.[cardID]?.nameValuePairs?.issuedBy;
const shouldDisplayCardDomain = !cardList?.[cardID]?.nameValuePairs?.issuedBy || !cardList?.[cardID]?.nameValuePairs?.isVirtual;
const domain = cardList?.[cardID]?.domainName ?? '';
const pageTitle = shouldDisplayCardDomain ? translate('cardPage.expensifyCard') : cardList?.[cardID]?.nameValuePairs?.cardTitle ?? translate('cardPage.expensifyCard');

const [isNotFound, setIsNotFound] = useState(false);
const cardsToShow = useMemo(() => {
if (shouldDisplayCardDomain) {
return CardUtils.getDomainCards(cardList)[domain]?.filter((card) => !card?.nameValuePairs?.issuedBy) ?? [];
return CardUtils.getDomainCards(cardList)[domain]?.filter((card) => !card?.nameValuePairs?.issuedBy || !card?.nameValuePairs?.isVirtual) ?? [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit confused about this logic. But from the OG PR: #38998

Cards from the same domain are grouped under the same card row when card is not issued by an admin. When card was issued by the admin then this card will have it's own separate row.

So then it makes sense that we're excluding admin-issued virtual cards

}
return [cardList?.[cardID]];
}, [shouldDisplayCardDomain, cardList, cardID, domain]);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/settings/Wallet/PaymentMethodList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function PaymentMethodList({
return;
}

const isAdminIssuedVirtualCard = !!card?.nameValuePairs?.issuedBy;
const isAdminIssuedVirtualCard = !!card?.nameValuePairs?.issuedBy && !!card?.nameValuePairs?.isVirtual;

// The card should be grouped to a specific domain and such domain already exists in a assignedCardsGrouped
if (assignedCardsGrouped.some((item) => item.isGroupedCardDomain && item.description === card.domainName) && !isAdminIssuedVirtualCard) {
Expand All @@ -242,7 +242,7 @@ function PaymentMethodList({
assignedCardsGrouped.push({
key: card.cardID.toString(),
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
title: isAdminIssuedVirtualCard ? card?.nameValuePairs?.cardTitle || card.bank : card.bank,
title: card?.nameValuePairs?.cardTitle || card.bank,
description: card.domainName,
onPress: () => Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(String(card.cardID))),
isGroupedCardDomain: !isAdminIssuedVirtualCard,
Expand Down
Loading