Skip to content

Commit 3c3eb17

Browse files
MelvinBotishpaul777
andcommitted
Fix: Remove generic error from failureData and move public domain check before disable toggle
Remove the hardcoded generic error message from toggleTravelInvoicing failureData so server-provided error messages are preserved. Move the public domain check to the top of handleToggle so it runs for both enable and disable actions. Co-authored-by: Ishpaul Singh <ishpaul777@users.noreply.github.com>
1 parent f3f5d3e commit 3c3eb17

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/libs/actions/TravelInvoicing.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ function toggleTravelInvoicing(policyID: string, workspaceAccountID: number, ena
288288
isEnabled: !enabled,
289289
},
290290
pendingAction: null,
291-
errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
292291
},
293292
},
294293
];

src/pages/workspace/travel/WorkspaceTravelInvoicingSection.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ function WorkspaceTravelInvoicingSection({policyID}: WorkspaceTravelInvoicingSec
115115
* When turning OFF: show confirmation modal, then call toggleTravelInvoicing(false).
116116
*/
117117
const handleToggle = (isEnabled: boolean) => {
118+
// Check if user is on a public domain - Travel Invoicing requires a private domain
119+
if (account?.isFromPublicDomain) {
120+
Navigation.navigate(ROUTES.TRAVEL_PUBLIC_DOMAIN_ERROR.getRoute(Navigation.getActiveRoute()));
121+
return;
122+
}
123+
118124
if (!isEnabled) {
119125
// Trying to disable - check for outstanding balance first
120126
if (hasOutstandingTravelBalance(cardSettings)) {
@@ -127,12 +133,6 @@ function WorkspaceTravelInvoicingSection({policyID}: WorkspaceTravelInvoicingSec
127133
return;
128134
}
129135

130-
// Check if user is on a public domain - Travel Invoicing requires a private domain
131-
if (account?.isFromPublicDomain) {
132-
Navigation.navigate(ROUTES.TRAVEL_PUBLIC_DOMAIN_ERROR.getRoute(Navigation.getActiveRoute()));
133-
return;
134-
}
135-
136136
// Turning ON - check if bank account setup is needed first
137137
if (!eligibleBankAccounts.length || isSetupUnfinished) {
138138
// No bank accounts - start add bank account flow

0 commit comments

Comments
 (0)