Skip to content

Commit 846f896

Browse files
authored
Merge pull request Expensify#68525 from callstack-internal/remove-broken-connection-for-commercial-feed
Remove broken connection for commercial feed with lastScrapeResult equal 531
2 parents 6761677 + f149097 commit 846f896

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

src/CONST/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ const connectionsVideoPaths = {
9191
// Explicit type annotation is required
9292
const cardActiveStates: number[] = [2, 3, 4, 7];
9393

94+
const brokenConnectionScrapeStatuses: number[] = [200, 531, 530, 500, 666];
95+
9496
// Hide not issued or not activated cards (states 2, 4) from card filter options in search, as no transactions can be made on cards in these states
9597
const cardHiddenFromSearchStates: number[] = [2, 4];
9698

@@ -3269,6 +3271,7 @@ const CONST = {
32693271
MANAGE_EXPENSIFY_CARDS_ARTICLE_LINK: 'https://help.expensify.com/articles/new-expensify/expensify-card/Manage-Expensify-Cards',
32703272
},
32713273
COMPANY_CARDS: {
3274+
BROKEN_CONNECTION_IGNORED_STATUSES: brokenConnectionScrapeStatuses,
32723275
CONNECTION_ERROR: 'connectionError',
32733276
STEP: {
32743277
SELECT_BANK: 'SelectBank',

src/libs/CardUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,9 @@ function checkIfFeedConnectionIsBroken(feedCards: Record<string, Card> | undefin
637637
return false;
638638
}
639639

640-
return Object.values(feedCards).some((card) => !isEmptyObject(card) && card.bank !== feedToExclude && card.lastScrapeResult !== 200);
640+
return Object.values(feedCards).some(
641+
(card) => !isEmptyObject(card) && card.bank !== feedToExclude && card.lastScrapeResult && !CONST.COMPANY_CARDS.BROKEN_CONNECTION_IGNORED_STATUSES.includes(card.lastScrapeResult),
642+
);
641643
}
642644

643645
/**

tests/unit/CardUtilsTest.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ const directFeedCardsSingleList: WorkspaceCardsList = {
149149
state: 3,
150150
},
151151
};
152+
153+
const commercialFeedCardsSingleList: WorkspaceCardsList = {
154+
// eslint-disable-next-line @typescript-eslint/naming-convention
155+
'21570652': {
156+
accountID: 18439984,
157+
bank: CONST.COMPANY_CARD.FEED_BANK_NAME.CHASE,
158+
cardID: 21570652,
159+
cardName: 'CREDIT CARD...5501',
160+
domainName: 'expensify-policy17f617b9fe23d2f1.exfy',
161+
fraud: 'none',
162+
lastFourPAN: '5501',
163+
lastScrape: '',
164+
lastUpdated: '',
165+
lastScrapeResult: 531,
166+
scrapeMinDate: '2024-08-27',
167+
state: 3,
168+
},
169+
};
152170
const directFeedCardsMultipleList: WorkspaceCardsList = {
153171
// eslint-disable-next-line @typescript-eslint/naming-convention
154172
'21570655': {
@@ -798,6 +816,10 @@ describe('CardUtils', () => {
798816
expect(checkIfFeedConnectionIsBroken(directFeedCardsSingleList)).toBeFalsy();
799817
});
800818

819+
it('should return false if all of the feed(s) cards has the lastScrapeResult equal to 531', () => {
820+
expect(checkIfFeedConnectionIsBroken(commercialFeedCardsSingleList)).toBeFalsy();
821+
});
822+
801823
it('should return false if no feed(s) cards are provided', () => {
802824
expect(checkIfFeedConnectionIsBroken({})).toBeFalsy();
803825
});

tests/unit/useAccountTabIndicatorStatusTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ const getMockForStatus = (status: string) =>
8686
// eslint-disable-next-line @typescript-eslint/naming-convention
8787
card123: {
8888
bank: 'OTHER_BANK',
89-
lastScrapeResult: status === CONST.INDICATOR_STATUS.HAS_CARD_CONNECTION_ERROR ? 500 : 200,
89+
lastScrapeResult: status === CONST.INDICATOR_STATUS.HAS_CARD_CONNECTION_ERROR ? 403 : 200,
9090
},
9191
// eslint-disable-next-line @typescript-eslint/naming-convention
9292
card456: {
9393
bank: 'ANOTHER_BANK',
94-
lastScrapeResult: status === CONST.INDICATOR_STATUS.HAS_CARD_CONNECTION_ERROR ? 500 : 200,
94+
lastScrapeResult: status === CONST.INDICATOR_STATUS.HAS_CARD_CONNECTION_ERROR ? 403 : 200,
9595
},
9696
},
9797
[ONYXKEYS.SESSION]: {

0 commit comments

Comments
 (0)