Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/libs/actions/TravelInvoicing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ function toggleTravelInvoicing(policyID: string, workspaceAccountID: number, ena
isEnabled: !enabled,
},
pendingAction: null,
errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
},
},
];
Expand Down
12 changes: 6 additions & 6 deletions src/pages/workspace/travel/WorkspaceTravelInvoicingSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/unit/TravelInvoicingTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ describe('TravelInvoicing', () => {
isEnabled: !enabled,
}),
pendingAction: null,
errors: expect.anything() as unknown,
}),
}),
]),
Expand Down
Loading