diff --git a/src/libs/actions/TravelInvoicing.ts b/src/libs/actions/TravelInvoicing.ts index 563afc05da738..c0d31587e1622 100644 --- a/src/libs/actions/TravelInvoicing.ts +++ b/src/libs/actions/TravelInvoicing.ts @@ -288,7 +288,6 @@ function toggleTravelInvoicing(policyID: string, workspaceAccountID: number, ena isEnabled: !enabled, }, pendingAction: null, - errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), }, }, ]; diff --git a/src/pages/workspace/travel/WorkspaceTravelInvoicingSection.tsx b/src/pages/workspace/travel/WorkspaceTravelInvoicingSection.tsx index a2486c9e34e52..faad6eb8e160d 100644 --- a/src/pages/workspace/travel/WorkspaceTravelInvoicingSection.tsx +++ b/src/pages/workspace/travel/WorkspaceTravelInvoicingSection.tsx @@ -115,6 +115,12 @@ function WorkspaceTravelInvoicingSection({policyID}: WorkspaceTravelInvoicingSec * When turning OFF: show confirmation modal, then call toggleTravelInvoicing(false). */ const handleToggle = (isEnabled: boolean) => { + // Check if user is on a public domain - Travel Invoicing requires a private domain + if (account?.isFromPublicDomain) { + Navigation.navigate(ROUTES.TRAVEL_PUBLIC_DOMAIN_ERROR.getRoute(Navigation.getActiveRoute())); + return; + } + if (!isEnabled) { // Trying to disable - check for outstanding balance first if (hasOutstandingTravelBalance(cardSettings)) { @@ -127,12 +133,6 @@ function WorkspaceTravelInvoicingSection({policyID}: WorkspaceTravelInvoicingSec return; } - // Check if user is on a public domain - Travel Invoicing requires a private domain - if (account?.isFromPublicDomain) { - Navigation.navigate(ROUTES.TRAVEL_PUBLIC_DOMAIN_ERROR.getRoute(Navigation.getActiveRoute())); - return; - } - // Turning ON - check if bank account setup is needed first if (!eligibleBankAccounts.length || isSetupUnfinished) { // No bank accounts - start add bank account flow diff --git a/tests/unit/TravelInvoicingTest.ts b/tests/unit/TravelInvoicingTest.ts index f4227a3abfd8c..ee4e4da15e070 100644 --- a/tests/unit/TravelInvoicingTest.ts +++ b/tests/unit/TravelInvoicingTest.ts @@ -250,7 +250,6 @@ describe('TravelInvoicing', () => { isEnabled: !enabled, }), pendingAction: null, - errors: expect.anything() as unknown, }), }), ]),