From b6fc76b181f3df78ae8e5cfdc3ebb4f8d8cc0629 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Mon, 16 Mar 2026 19:59:22 -0700 Subject: [PATCH 1/2] fix: remove isTravelCVVTestingEnabled and fallback card logic --- src/libs/TravelInvoicingUtils.ts | 20 +---------- tests/unit/TravelInvoicingUtilsTest.ts | 49 -------------------------- 2 files changed, 1 insertion(+), 68 deletions(-) diff --git a/src/libs/TravelInvoicingUtils.ts b/src/libs/TravelInvoicingUtils.ts index 2ea48200e0864..6e8cfd350265b 100644 --- a/src/libs/TravelInvoicingUtils.ts +++ b/src/libs/TravelInvoicingUtils.ts @@ -6,19 +6,8 @@ import type {BankAccountList, Card, CardList} from '@src/types/onyx'; import type {ExpensifyCardSettingsBase} from '@src/types/onyx/ExpensifyCardSettings'; import addEncryptedAuthTokenToURL from './addEncryptedAuthTokenToURL'; import {getLastFourDigits} from './BankAccountUtils'; -import {isDevelopment, isInternalTestBuild, isStaging} from './Environment/Environment'; import fileDownload from './fileDownload'; -/** - * Feature flag to enable Travel CVV testing on Dev and Staging environments. - * When enabled, it allows using any card for CVV reveal testing if no specific Travel Card is found. - * - * TODO: Remove this function and associated logic when Travel Invoicing is fully released - */ -function isTravelCVVTestingEnabled(): boolean { - return isDevelopment() || isStaging() || isInternalTestBuild(); -} - /** * Checks whether Travel Invoicing is enabled based on the card settings. * Returns true if: @@ -171,13 +160,7 @@ function getTravelInvoicingCard(cardList: OnyxEntry) { } const allCards = Object.values(cardList).filter((card): card is Card => !!card && typeof card?.cardID === 'number'); - const travelCard = allCards.find((card) => card.nameValuePairs?.feedCountry === CONST.TRAVEL.PROGRAM_TRAVEL_US); - // If no travel card is found and testing is enabled, return the first available card - if (!travelCard && isTravelCVVTestingEnabled()) { - return allCards.find((card) => card.bank === CONST.EXPENSIFY_CARD.BANK); - } - - return travelCard; + return allCards.find((card) => card.nameValuePairs?.feedCountry === CONST.TRAVEL.PROGRAM_TRAVEL_US); } /** @@ -201,7 +184,6 @@ export { downloadTravelInvoiceStatementPDF, getTravelInvoicingCard, isTravelCVVEligible, - isTravelCVVTestingEnabled, }; export type {TravelSettlementAccountInfo}; diff --git a/tests/unit/TravelInvoicingUtilsTest.ts b/tests/unit/TravelInvoicingUtilsTest.ts index 4042cd9c35ae2..a07a951f3b877 100644 --- a/tests/unit/TravelInvoicingUtilsTest.ts +++ b/tests/unit/TravelInvoicingUtilsTest.ts @@ -1,7 +1,4 @@ import CONST from '@src/CONST'; -// Needed for testing usage with jest.spyOn -// eslint-disable-next-line no-restricted-imports -import * as Environment from '@src/libs/Environment/Environment'; import { getIsTravelInvoicingEnabled, getTravelInvoicingCard, @@ -15,28 +12,7 @@ import { import type {BankAccountList, CardList} from '@src/types/onyx'; import type {ExpensifyCardSettingsBase} from '@src/types/onyx/ExpensifyCardSettings'; -jest.mock('@src/libs/Environment/Environment', () => ({ - getEnvironmentURL: jest.fn(() => Promise.resolve('https://new.expensify.com')), - getOldDotEnvironmentURL: jest.fn(() => Promise.resolve('https://www.expensify.com')), - isDevelopment: jest.fn(() => false), - isInternalTestBuild: jest.fn(() => false), - isStaging: jest.fn(() => false), -})); - describe('TravelInvoicingUtils', () => { - let isDevelopmentSpy: jest.SpyInstance; - let isInternalTestBuildSpy: jest.SpyInstance; - - beforeAll(() => { - isDevelopmentSpy = jest.spyOn(Environment, 'isDevelopment').mockReturnValue(false); - isInternalTestBuildSpy = jest.spyOn(Environment, 'isInternalTestBuild').mockReturnValue(false); - }); - - afterEach(() => { - isDevelopmentSpy.mockReturnValue(false); - isInternalTestBuildSpy.mockReturnValue(false); - jest.clearAllMocks(); - }); describe('PROGRAM_TRAVEL_US constant', () => { it('Should be defined as TRAVEL_US', () => { expect(CONST.TRAVEL.PROGRAM_TRAVEL_US).toBe('TRAVEL_US'); @@ -298,26 +274,6 @@ describe('TravelInvoicingUtils', () => { expect(result).toBeDefined(); expect(result?.nameValuePairs?.feedCountry).toBe(CONST.TRAVEL.PROGRAM_TRAVEL_US); }); - it('Should fallback to first available card when testing is enabled and no travel card exists', () => { - isDevelopmentSpy.mockReturnValue(true); - - const cardList = { - // eslint-disable-next-line @typescript-eslint/naming-convention - '9999': { - cardID: 9999, - state: 3, - bank: 'Expensify Card', - nameValuePairs: { - isVirtual: true, - feedCountry: 'OTHER_COUNTRY', - }, - }, - } as unknown as CardList; - - const result = getTravelInvoicingCard(cardList); - expect(result).toBeDefined(); - expect(result?.cardID).toBe(9999); - }); }); describe('isTravelCVVEligible', () => { @@ -371,10 +327,5 @@ describe('TravelInvoicingUtils', () => { expect(result).toBe(true); }); - it('Should return true when testing is enabled and beta is true even if no travel card exists', () => { - isDevelopmentSpy.mockReturnValue(true); - const result = isTravelCVVEligible(true, mockNonTravelCardList); - expect(result).toBe(true); - }); }); }); From 19248dfeede64ad9e0fa348dfe11571569630671 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Mon, 16 Mar 2026 20:00:59 -0700 Subject: [PATCH 2/2] chore: prettier --- tests/unit/TravelInvoicingUtilsTest.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/TravelInvoicingUtilsTest.ts b/tests/unit/TravelInvoicingUtilsTest.ts index a07a951f3b877..736621a9031e9 100644 --- a/tests/unit/TravelInvoicingUtilsTest.ts +++ b/tests/unit/TravelInvoicingUtilsTest.ts @@ -326,6 +326,5 @@ describe('TravelInvoicingUtils', () => { const result = isTravelCVVEligible(true, mockTravelCardList); expect(result).toBe(true); }); - }); });