From e348b4abf735c291b5a47f318f2e9bd9889cfec0 Mon Sep 17 00:00:00 2001
From: Georgia Monahan <georgia@expensify.com>
Date: Tue, 28 Nov 2023 10:33:29 +0000
Subject: [PATCH 1/3] Check for cardID in cardList

---
 src/libs/CardUtils.ts        | 14 +++++++++++++-
 src/libs/TransactionUtils.ts |  5 +++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/libs/CardUtils.ts b/src/libs/CardUtils.ts
index 0dc483aff50e..dee03476b755 100644
--- a/src/libs/CardUtils.ts
+++ b/src/libs/CardUtils.ts
@@ -37,6 +37,18 @@ function isExpensifyCard(cardID: number) {
     return card.bank === CONST.EXPENSIFY_CARD.BANK;
 }
 
+/**
+ * @param cardID
+ * @returns boolean
+ */
+function isCompanyCard(cardID: number) {
+    const card = allCards[cardID];
+    if (!card) {
+        return false;
+    }
+    return true;
+}
+
 /**
  * @param cardID
  * @returns string in format %<bank> - <lastFourPAN || Not Activated>%.
@@ -99,4 +111,4 @@ function findPhysicalCard(cards: Card[]) {
     return cards.find((card) => !card.isVirtual);
 }
 
-export {isExpensifyCard, getDomainCards, getMonthFromExpirationDateString, getYearFromExpirationDateString, maskCard, getCardDescription, findPhysicalCard};
+export {isExpensifyCard, isCompanyCard, getDomainCards, getMonthFromExpirationDateString, getYearFromExpirationDateString, maskCard, getCardDescription, findPhysicalCard};
diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts
index 763c8d19f800..e4dd9ebcadda 100644
--- a/src/libs/TransactionUtils.ts
+++ b/src/libs/TransactionUtils.ts
@@ -5,7 +5,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
 import {RecentWaypoint, ReportAction, Transaction} from '@src/types/onyx';
 import {Comment, Receipt, Waypoint, WaypointCollection} from '@src/types/onyx/Transaction';
 import {EmptyObject} from '@src/types/utils/EmptyObject';
-import {isExpensifyCard} from './CardUtils';
+import {isExpensifyCard, isCompanyCard} from './CardUtils';
 import DateUtils from './DateUtils';
 import * as NumberUtils from './NumberUtils';
 
@@ -338,7 +338,8 @@ function isExpensifyCardTransaction(transaction: Transaction): boolean {
  * Determine whether a transaction is made with a card.
  */
 function isCardTransaction(transaction: Transaction): boolean {
-    return (transaction?.cardID ?? 0) > 0;
+    const cardID = transaction?.cardID ?? 0;
+    return isCompanyCard(cardID);
 }
 
 /**

From 55a1b87f9291c4ce43508684cc53df9860fb3f40 Mon Sep 17 00:00:00 2001
From: Georgia Monahan <georgia@expensify.com>
Date: Tue, 28 Nov 2023 10:39:41 +0000
Subject: [PATCH 2/3] rename function

---
 src/libs/CardUtils.ts        | 4 ++--
 src/libs/TransactionUtils.ts | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/libs/CardUtils.ts b/src/libs/CardUtils.ts
index dee03476b755..b6d1deba2a14 100644
--- a/src/libs/CardUtils.ts
+++ b/src/libs/CardUtils.ts
@@ -41,7 +41,7 @@ function isExpensifyCard(cardID: number) {
  * @param cardID
  * @returns boolean
  */
-function isCompanyCard(cardID: number) {
+function isCardListCard(cardID: number) {
     const card = allCards[cardID];
     if (!card) {
         return false;
@@ -111,4 +111,4 @@ function findPhysicalCard(cards: Card[]) {
     return cards.find((card) => !card.isVirtual);
 }
 
-export {isExpensifyCard, isCompanyCard, getDomainCards, getMonthFromExpirationDateString, getYearFromExpirationDateString, maskCard, getCardDescription, findPhysicalCard};
+export {isExpensifyCard, isCardListCard, getDomainCards, getMonthFromExpirationDateString, getYearFromExpirationDateString, maskCard, getCardDescription, findPhysicalCard};
diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts
index e4dd9ebcadda..710ce0e65768 100644
--- a/src/libs/TransactionUtils.ts
+++ b/src/libs/TransactionUtils.ts
@@ -5,7 +5,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
 import {RecentWaypoint, ReportAction, Transaction} from '@src/types/onyx';
 import {Comment, Receipt, Waypoint, WaypointCollection} from '@src/types/onyx/Transaction';
 import {EmptyObject} from '@src/types/utils/EmptyObject';
-import {isExpensifyCard, isCompanyCard} from './CardUtils';
+import {isCardListCard, isExpensifyCard} from './CardUtils';
 import DateUtils from './DateUtils';
 import * as NumberUtils from './NumberUtils';
 
@@ -335,11 +335,11 @@ function isExpensifyCardTransaction(transaction: Transaction): boolean {
 }
 
 /**
- * Determine whether a transaction is made with a card.
+ * Determine whether a transaction is made with a card (Expensify or Company Card).
  */
 function isCardTransaction(transaction: Transaction): boolean {
     const cardID = transaction?.cardID ?? 0;
-    return isCompanyCard(cardID);
+    return isCardListCard(cardID);
 }
 
 /**

From 030cfe1da1293c388667cd6444b11e75e9a9e5a8 Mon Sep 17 00:00:00 2001
From: Georgia Monahan <georgia@expensify.com>
Date: Tue, 28 Nov 2023 12:58:36 +0000
Subject: [PATCH 3/3] rename function and simplify

---
 src/libs/CardUtils.ts        | 12 ++++--------
 src/libs/TransactionUtils.ts |  4 ++--
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/libs/CardUtils.ts b/src/libs/CardUtils.ts
index b6d1deba2a14..b0d426c9774a 100644
--- a/src/libs/CardUtils.ts
+++ b/src/libs/CardUtils.ts
@@ -39,14 +39,10 @@ function isExpensifyCard(cardID: number) {
 
 /**
  * @param cardID
- * @returns boolean
+ * @returns boolean if the cardID is in the cardList from ONYX. Includes Expensify Cards.
  */
-function isCardListCard(cardID: number) {
-    const card = allCards[cardID];
-    if (!card) {
-        return false;
-    }
-    return true;
+function isCorporateCard(cardID: number) {
+    return !!allCards[cardID];
 }
 
 /**
@@ -111,4 +107,4 @@ function findPhysicalCard(cards: Card[]) {
     return cards.find((card) => !card.isVirtual);
 }
 
-export {isExpensifyCard, isCardListCard, getDomainCards, getMonthFromExpirationDateString, getYearFromExpirationDateString, maskCard, getCardDescription, findPhysicalCard};
+export {isExpensifyCard, isCorporateCard, getDomainCards, getMonthFromExpirationDateString, getYearFromExpirationDateString, maskCard, getCardDescription, findPhysicalCard};
diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts
index 710ce0e65768..d03235a637c7 100644
--- a/src/libs/TransactionUtils.ts
+++ b/src/libs/TransactionUtils.ts
@@ -5,7 +5,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
 import {RecentWaypoint, ReportAction, Transaction} from '@src/types/onyx';
 import {Comment, Receipt, Waypoint, WaypointCollection} from '@src/types/onyx/Transaction';
 import {EmptyObject} from '@src/types/utils/EmptyObject';
-import {isCardListCard, isExpensifyCard} from './CardUtils';
+import {isCorporateCard, isExpensifyCard} from './CardUtils';
 import DateUtils from './DateUtils';
 import * as NumberUtils from './NumberUtils';
 
@@ -339,7 +339,7 @@ function isExpensifyCardTransaction(transaction: Transaction): boolean {
  */
 function isCardTransaction(transaction: Transaction): boolean {
     const cardID = transaction?.cardID ?? 0;
-    return isCardListCard(cardID);
+    return isCorporateCard(cardID);
 }
 
 /**
