diff --git a/src/libs/CardUtils.ts b/src/libs/CardUtils.ts index d0f530a7632d..12d958d8b701 100644 --- a/src/libs/CardUtils.ts +++ b/src/libs/CardUtils.ts @@ -575,7 +575,7 @@ function getAllCardsForWorkspace( .map((key) => key.split('_').at(-1)) .filter((id): id is string => !!id); for (const [key, values] of Object.entries(allCardList ?? {})) { - const isWorkspaceAccountCards = key.includes(workspaceAccountID.toString()); + const isWorkspaceAccountCards = workspaceAccountID !== CONST.DEFAULT_NUMBER_ID && key.includes(workspaceAccountID.toString()); const isCompanyDomainCards = companyCardsDomainFeeds?.some((domainFeed) => domainFeed.domainID && key.includes(domainFeed.domainID.toString()) && key.includes(domainFeed.feedName)); const isExpensifyDomainCards = expensifyCardsDomainIDs.some((domainID) => key.includes(domainID.toString()) && key.includes(CONST.EXPENSIFY_CARD.BANK)); if ((isWorkspaceAccountCards || isCompanyDomainCards || isExpensifyDomainCards) && values) { diff --git a/tests/unit/CardUtilsTest.ts b/tests/unit/CardUtilsTest.ts index b0aa29d56096..f528e7ac30f3 100644 --- a/tests/unit/CardUtilsTest.ts +++ b/tests/unit/CardUtilsTest.ts @@ -281,6 +281,20 @@ const allCardsList = { state: 2, }, }, + 'cards_10101_Expensify Card': { + '21570657': { + accountID: 18439984, + bank: CONST.EXPENSIFY_CARD.BANK, + cardID: 21570657, + cardName: 'CREDIT CARD...5644', + domainName: 'expensify-policy17f617b9fe23d2f1.exfy', + fraud: 'none', + lastFourPAN: '', + lastScrape: '', + lastUpdated: '', + state: 2, + }, + }, } as OnyxCollection; const mockIllustrations = { @@ -819,6 +833,11 @@ describe('CardUtils', () => { const workspaceAccountID = 11111111; expect(hasIssuedExpensifyCard(workspaceAccountID, {})).toBe(false); }); + + it('should not erroneously return true when workspaceAccountID is 0', () => { + const workspaceAccountID = 0; + expect(hasIssuedExpensifyCard(workspaceAccountID, allCardsList)).toBe(false); + }); }); describe('isExpensifyCardFullySetUp', () => {