From 1e796875b4ea0812f7dd565d1cade3c365317b28 Mon Sep 17 00:00:00 2001
From: Vit Horacek <vit@expensify.com>
Date: Fri, 24 Jan 2025 17:16:45 +0100
Subject: [PATCH 1/3] Update the custom feed method

---
 src/libs/CardUtils.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libs/CardUtils.ts b/src/libs/CardUtils.ts
index 1d697af554f5..71278e7d404e 100644
--- a/src/libs/CardUtils.ts
+++ b/src/libs/CardUtils.ts
@@ -288,7 +288,7 @@ function getCardFeedIcon(cardFeed: CompanyCardFeed | typeof CONST.EXPENSIFY_CARD
  * Verify if the feed is a custom feed. Those are also refered to as commercial feeds.
  */
 function isCustomFeed(feed: CompanyCardFeed): boolean {
-    return [CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD, CONST.COMPANY_CARD.FEED_BANK_NAME.VISA, CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX].some((value) => value === feed);
+    return [CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD, CONST.COMPANY_CARD.FEED_BANK_NAME.VISA, CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX].some((value) => feed.startsWith(value));
 }
 
 function getCompanyFeeds(cardFeeds: OnyxEntry<CardFeeds>, shouldFilterOutRemovedFeeds = false): CompanyFeeds {

From 0101f1c6fc762b8f0f1a0eb0c6c6ee9ea862259a Mon Sep 17 00:00:00 2001
From: Vit Horacek <vit@expensify.com>
Date: Fri, 24 Jan 2025 17:25:41 +0100
Subject: [PATCH 2/3] Update the isCustom param type and add more tests

---
 src/libs/CardUtils.ts       |  2 +-
 tests/unit/CardUtilsTest.ts | 47 ++++++++++++++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/src/libs/CardUtils.ts b/src/libs/CardUtils.ts
index 71278e7d404e..81e77d565db3 100644
--- a/src/libs/CardUtils.ts
+++ b/src/libs/CardUtils.ts
@@ -287,7 +287,7 @@ function getCardFeedIcon(cardFeed: CompanyCardFeed | typeof CONST.EXPENSIFY_CARD
 /**
  * Verify if the feed is a custom feed. Those are also refered to as commercial feeds.
  */
-function isCustomFeed(feed: CompanyCardFeed): boolean {
+function isCustomFeed(feed: CompanyCardFeedWithNumber): boolean {
     return [CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD, CONST.COMPANY_CARD.FEED_BANK_NAME.VISA, CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX].some((value) => feed.startsWith(value));
 }
 
diff --git a/tests/unit/CardUtilsTest.ts b/tests/unit/CardUtilsTest.ts
index 0ac8de13c8c8..7f9df53f63eb 100644
--- a/tests/unit/CardUtilsTest.ts
+++ b/tests/unit/CardUtilsTest.ts
@@ -2,6 +2,7 @@ import type {OnyxCollection} from 'react-native-onyx';
 import CONST from '@src/CONST';
 import * as CardUtils from '@src/libs/CardUtils';
 import type * as OnyxTypes from '@src/types/onyx';
+import type {CompanyCardFeedWithNumber} from '@src/types/onyx/CardFeeds';
 
 const shortDate = '0924';
 const shortDateSlashed = '09/24';
@@ -12,6 +13,17 @@ const longDateHyphen = '09-2024';
 const expectedMonth = '09';
 const expectedYear = '2024';
 
+const directFeedBanks = [
+    CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX_DIRECT,
+    CONST.COMPANY_CARD.FEED_BANK_NAME.BANK_OF_AMERICA,
+    CONST.COMPANY_CARD.FEED_BANK_NAME.BREX,
+    CONST.COMPANY_CARD.FEED_BANK_NAME.CAPITAL_ONE,
+    CONST.COMPANY_CARD.FEED_BANK_NAME.CHASE,
+    CONST.COMPANY_CARD.FEED_BANK_NAME.CITIBANK,
+    CONST.COMPANY_CARD.FEED_BANK_NAME.STRIPE,
+    CONST.COMPANY_CARD.FEED_BANK_NAME.WELLS_FARGO,
+];
+
 const companyCardsCustomFeedSettings = {
     [CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD]: {
         pending: true,
@@ -232,14 +244,43 @@ describe('CardUtils', () => {
     });
 
     describe('isCustomFeed', () => {
-        it('Should return true for the custom feed', () => {
+        it('Should return true for the custom visa feed with no number', () => {
             const customFeed = CONST.COMPANY_CARD.FEED_BANK_NAME.VISA;
             const isCustomFeed = CardUtils.isCustomFeed(customFeed);
             expect(isCustomFeed).toBe(true);
         });
 
-        it('Should return false for the direct feed', () => {
-            const directFeed = CONST.COMPANY_CARD.FEED_BANK_NAME.CHASE;
+        it('Should return true for the custom visa feed with a number', () => {
+            const customFeed = `${CONST.COMPANY_CARD.FEED_BANK_NAME.VISA}1` as CompanyCardFeedWithNumber;
+            const isCustomFeed = CardUtils.isCustomFeed(customFeed);
+            expect(isCustomFeed).toBe(true);
+        });
+
+        it('Should return true for the custom mastercard feed with no number', () => {
+            const customFeed = CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD;
+            const isCustomFeed = CardUtils.isCustomFeed(customFeed);
+            expect(isCustomFeed).toBe(true);
+        });
+
+        it('Should return true for the custom mastercard feed with a number', () => {
+            const customFeed = `${CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD}1` as CompanyCardFeedWithNumber;
+            const isCustomFeed = CardUtils.isCustomFeed(customFeed);
+            expect(isCustomFeed).toBe(true);
+        });
+
+        it('Should return true for the custom amex feed with no number', () => {
+            const customFeed = CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX;
+            const isCustomFeed = CardUtils.isCustomFeed(customFeed);
+            expect(isCustomFeed).toBe(true);
+        });
+
+        it('Should return true for the custom amex feed with a number', () => {
+            const customFeed = `${CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX}1` as CompanyCardFeedWithNumber;
+            const isCustomFeed = CardUtils.isCustomFeed(customFeed);
+            expect(isCustomFeed).toBe(true);
+        });
+
+        test.each(directFeedBanks)('Should return false for the direct feed %s', (directFeed) => {
             const isCustomFeed = CardUtils.isCustomFeed(directFeed);
             expect(isCustomFeed).toBe(false);
         });

From e4d2af055d3188f25cdcad268e40e59710b95578 Mon Sep 17 00:00:00 2001
From: Vit Horacek <vit@expensify.com>
Date: Fri, 24 Jan 2025 17:27:32 +0100
Subject: [PATCH 3/3] Use different numbers

---
 tests/unit/CardUtilsTest.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/unit/CardUtilsTest.ts b/tests/unit/CardUtilsTest.ts
index 7f9df53f63eb..642494d6ed11 100644
--- a/tests/unit/CardUtilsTest.ts
+++ b/tests/unit/CardUtilsTest.ts
@@ -263,7 +263,7 @@ describe('CardUtils', () => {
         });
 
         it('Should return true for the custom mastercard feed with a number', () => {
-            const customFeed = `${CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD}1` as CompanyCardFeedWithNumber;
+            const customFeed = `${CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD}3` as CompanyCardFeedWithNumber;
             const isCustomFeed = CardUtils.isCustomFeed(customFeed);
             expect(isCustomFeed).toBe(true);
         });
@@ -275,7 +275,7 @@ describe('CardUtils', () => {
         });
 
         it('Should return true for the custom amex feed with a number', () => {
-            const customFeed = `${CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX}1` as CompanyCardFeedWithNumber;
+            const customFeed = `${CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX}2` as CompanyCardFeedWithNumber;
             const isCustomFeed = CardUtils.isCustomFeed(customFeed);
             expect(isCustomFeed).toBe(true);
         });
