[Due for payment 2026-12-08] [$250] [Exploratory] Warning company still has Consolidated Travel Billing not shown when delete ws offline
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: v9.4.52-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/App/pull/96872 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Win 11/Chrome App Component: Workspace Settings
Action Performed:
Precondition:
- Use the Expensifail account
- Create a workspace enable Travel, click on Let's go and complete flow
- Enable Consolidated Travel Billing and add bank account to it
- Open https://staging.new.expensify.com
- Navigate to the Workspace tab or Overview
- Force offline
- Click on the three dots button -> Delete -> Confirm Delete
- Turn online
Expected Result:
Verify that Warning "Your company still has Consolidated Travel Billing enabled." shown
Actual Result:
Warning "Your company still has Consolidated Travel Billing enabled." isn't shown in offline. Turn online, the warning displays "Your company still has Expensify Cards"
Workaround:
Unknown
Platforms:
- [x] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/1f119a0b-3919-425f-a63d-c86d90a8ef82
Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7230786
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022119908040491759572
- Upwork Job ID: 2119908040491759572
- Last Price Increase: 2026-11-11
Issue Owner
Current Issue Owner: @cretadn22
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/06b678e2043ac8ec9e642faae8ccb6431e94f68a20bd4a1065211b7de9824102
@applause-bot[bot], this Monthly task hasn't been acted upon in 6 weeks; closing.
If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a workspace has Consolidated Travel Billing enabled (with a bank account added) and the user deletes that workspace while offline, no warning is shown — the workspace is optimistically deleted. When the user goes back online, the deletion is rejected and the warning that appears is the wrong one: "Your company still has Expensify Cards" instead of "Your company still has Consolidated Travel Billing enabled."
What is the root cause of that problem?
The delete-workspace flow has an offline pre-flight guard that blocks the deletion up front when the app already knows locally that the backend will reject it on reconnect. That guard only considers the Expensify Cards blocker and ignores the Consolidated Travel Billing blocker, even though isBlockedByTravelBilling is computed on the line right next to it:
https://github.com/Expensify/App/blob/eac6e9c188d4b8fceffa9531c6e4f17f3bf22438/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L117-L120
So when the only blocker is Consolidated Travel Billing and the user is offline, hasDeleteWorkspaceExpensifyCardsError stays false. Confirming the delete therefore takes the normal offline path: the workspace is optimistically deleted, the flow closes without showing any warning (which is why nothing appears while offline), and a DeleteWorkspace request is queued.
When connectivity returns, the backend rejects the queued request. Consolidated Travel Billing is implemented as a card feed on the workspace account (the flow itself checks it through the travel cards list), so the rejection surfaces with the backend's "still has Expensify Cards" wording — that error lands on the policy and is what gets displayed, producing the wrong warning the tester saw.
Additionally, even when the offline guard does fire, the error the action merges onto the policy is hardcoded to the Expensify Cards translation key regardless of which blocker actually applies:
https://github.com/Expensify/App/blob/eac6e9c188d4b8fceffa9531c6e4f17f3bf22438/src/libs/actions/Policy/Policy.ts#L465-L471
What changes do you think we should make in order to solve the problem?
In DeleteWorkspaceFlow, extend the offline pre-flight guard so it also blocks the deletion when the workspace is blocked by Consolidated Travel Billing — that is, the guard should be true while offline when either isBlockedByExpensifyCards or isBlockedByTravelBilling applies (and the variable should be renamed to reflect that it now covers both blockers). With that change, confirming the delete while offline goes down the existing early-error path, which calls showDeleteWorkspaceErrorModal. That callback already picks the correct copy — the Expensify Cards message when that blocker applies, otherwise the Consolidated Travel Billing message:
https://github.com/Expensify/App/blob/eac6e9c188d4b8fceffa9531c6e4f17f3bf22438/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L138-L150
As a result, the warning "Your company still has Consolidated Travel Billing enabled." shows immediately while offline (matching the expected result), and no doomed request is queued — so the wrong "Expensify Cards" warning after going back online disappears as well.
In the deleteWorkspace action, the offline pre-flight guard should merge the matching error onto the policy instead of always using the Expensify Cards key: the flow passes along the translation key of the blocker that applies (keeping Expensify Cards priority when both apply, consistent with the existing modal-copy priority), and the action merges the corresponding translation key. This keeps the error shown under the workspace row consistent with the modal copy.
This mirrors the exact offline behavior the flow already implements for Expensify Cards, so the fix follows the established pattern rather than introducing a new mechanism.
Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/98262-block-offline-travel-billing-delete?expand=1
What alternative solutions did you explore? (Optional)
Keeping the deletion flow mounted after an offline delete and latching the correct warning when the rejection arrives on reconnect. Rejected: the flow is intentionally unmounted right after an optimistic offline delete, and the backend's rejection wording for a Consolidated-Travel-Billing-blocked delete cannot be corrected from the App side — blocking up front while offline, exactly as the flow already does for Expensify Cards, is the established pattern and satisfies the expected result directly.
Job added to Upwork: https://www.upwork.com/jobs/~022119908012044806546
Triggered auto assignment to Contributor-plus team member for initial proposal review - @cretadn22 (External)
Job added to Upwork: https://www.upwork.com/jobs/~022119908040491759572
🤖 ProposalPolice™ is tracking duplicate proposals for this issue using an OpenAI Conversation. This comment stores that Conversation's ID and can be safely ignored.
Proposal
What is the root cause of that problem?
I found that the offline pre-flight guard was added specifically for Expensify Cards. It prevents a known-invalid deletion from being queued and stores the Expensify Cards error:
https://github.com/Expensify/App/blob/2553a8746e0eb6e2ba9124430a316372cbed54ea/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L108-L109
https://github.com/Expensify/App/blob/2553a8746e0eb6e2ba9124430a316372cbed54ea/src/libs/actions/Policy/Policy.ts#L434-L439
Travel Billing support was added later. The current flow now calculates both blockers, but the offline guard still checks only isBlockedByExpensifyCards:
https://github.com/Expensify/App/blob/243945ecd2c9a09cf6d72bbd32753aee4065d350/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L113-L120
Consequently, a Travel-Billing-only workspace gets the normal offline behavior: deleteWorkspace() queues the request, then the flow closes as though deletion succeeded.
https://github.com/Expensify/App/blob/243945ecd2c9a09cf6d72bbd32753aee4065d350/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L215-L241
There is a second part to the same root cause. The action accepts a boolean whose name and stored error are both specific to Expensify Cards. Reusing that boolean for Travel Billing alone would prevent the queued request, but it would still put the wrong Expensify Cards error on the policy:
https://github.com/Expensify/App/blob/243945ecd2c9a09cf6d72bbd32753aee4065d350/src/libs/actions/Policy/Policy.ts#L432-L468
What changes do you think we should make in order to solve the problem?
I think we should replace hasDeleteWorkspaceExpensifyCardsError with an optional offline blocker translation key. In DeleteWorkspaceFlow, derive it from both known blockers, retaining the existing Expensify Cards priority when both apply:
- const hasDeleteWorkspaceExpensifyCardsError = isBlockedByExpensifyCards && !!isOffline;
+ const deleteWorkspaceOfflineError = !isOffline
+ ? undefined
+ : isBlockedByExpensifyCards
+ ? 'workspace.common.deleteOpenExpensifyCardsError'
+ : isBlockedByTravelBilling
+ ? 'workspace.common.deleteTravelBillingError'
+ : undefined;
Pass that key to deleteWorkspace(). The action should return before creating optimistic API data when the key exists, and use the supplied key in getMicroSecondOnyxErrorWithTranslationKey() instead of hardcoding the Expensify Cards message. The flow should also use the same key when opening its error modal. This keeps the action state and visible warning in agreement.
The existing modal already supports the Travel Billing copy and establishes Expensify Cards as the priority when both blockers exist:
https://github.com/Expensify/App/blob/243945ecd2c9a09cf6d72bbd32753aee4065d350/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L138-L160
This does not change online deletion. It also preserves the current Expensify Cards behavior, while ordinary offline workspaces without either blocker continue through the optimistic queued-delete path. A Travel-Billing-only workspace is now stopped locally, shows “Your company still has Consolidated Travel Billing enabled,” and never queues the request that later produces the misleading server rejection.
What alternative solutions did you explore? (Optional)
I considered changing the existing boolean to isBlockedByExpensifyCards || isBlockedByTravelBilling. That fixes the missing offline guard, but the action would still persist deleteOpenExpensifyCardsError for Travel Billing. Passing the actual blocker key is a small change and fixes both the control flow and the error identity.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a workspace has Consolidated Travel Billing enabled and the user deletes it while offline, the "Your company still has Consolidated Travel Billing enabled" warning doesn't appear. The workspace gets deleted optimistically instead.
What is the root cause of that problem?
DeleteWorkspaceFlow already works out isBlockedByTravelBilling from local Onyx data (https://github.com/Expensify/App/blob/243945ecd2c9a09cf6d72bbd32753aee4065d350/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L118). But the offline pre-check only uses the Expensify Card blocker:
https://github.com/Expensify/App/blob/243945ecd2c9a09cf6d72bbd32753aee4065d350/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L120
const hasDeleteWorkspaceExpensifyCardsError = isBlockedByExpensifyCards && !!isOffline;
continueDeleteWorkspace only shows the blocker modal and skips the optimistic delete when this flag is true (https://github.com/Expensify/App/blob/243945ecd2c9a09cf6d72bbd32753aee4065d350/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L230-L240). Otherwise it goes down the isOffline branch, which closes the flow as if the delete worked. The travel-billing blocker is only checked in the online error effect (https://github.com/Expensify/App/blob/243945ecd2c9a09cf6d72bbd32753aee4065d350/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L292), which returns early when offline. So offline, travel billing never blocks the delete.
What changes do you think we should make in order to solve the problem?
Apply the offline pre-check to both blockers, the same way the online path does:
const hasDeleteWorkspaceBlockerError = (isBlockedByExpensifyCards || isBlockedByTravelBilling) && !!isOffline;
Then use it everywhere hasDeleteWorkspaceExpensifyCardsError is used (isConfirmLoading, the deleteWorkspace param and the modal branch). The existing modal already picks the travel billing text when Expensify Cards are not the blocker. Online behavior doesn't change.
Proposal updated — added compare branch with implementation.
Withdrawn — I'm withdrawing this proposal so I only hold one job at a time, per the contributor guidelines. Thank you for reviewing.
Original proposal
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a workspace has Consolidated Travel Billing enabled (with a linked bank account/travel cards) and a user attempts to delete the workspace while offline, the app does not show the blocker warning modal ("Your company still has Consolidated Travel Billing enabled."). Instead, it shows the delete confirmation modal, optimistically deletes the workspace, and queues the deletion request. When the app reconnects online, the backend rejects the deletion and the app displays the wrong warning message ("Your company still has Expensify Cards").
What is the root cause of that problem?
In src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx, the component defines two blocker conditions:
isBlockedByExpensifyCards: workspace has Expensify Cards enabled and active cards (hasExpensifyCardsEnabledOnWorkspace && hasExpensifyCards).isBlockedByTravelBilling: workspace has Consolidated Travel Billing enabled and active travel cards (hasTravelBillingEnabledOnWorkspace && hasTravelCards).
The error modal helper showDeleteWorkspaceErrorModal() is already implemented to handle both cases via:
html={translate(isBlockedByExpensifyCards ? 'workspace.common.deleteOpenExpensifyCardsError' : 'workspace.common.deleteTravelBillingError')}
However, the offline pre-flight guard at line 122 only checks isBlockedByExpensifyCards:
// While offline we can't get the real rejection reason from the backend, so if we already know locally that the workspace has active Expensify Cards, block the delete up front instead of queuing one that will fail on reconnect.
const hasDeleteWorkspaceExpensifyCardsError = isBlockedByExpensifyCards && !!isOffline;
Because isBlockedByTravelBilling was omitted from this guard:
- When a workspace only has Consolidated Travel Billing enabled and is offline,
hasDeleteWorkspaceExpensifyCardsErrorremainsfalse. - In the pre-deletion checks
useEffect, the early return that triggersshowDeleteWorkspaceErrorModal()is bypassed. - The flow proceeds to
continueDeleteWorkspace(), allowing the user to confirm the deletion while offline. deleteWorkspaceinsrc/libs/actions/Policy/Policy.tsexecutes optimistically and persists the request.- On reconnect, the backend rejects the queued command. Because Consolidated Travel Billing shares the underlying card feed architecture on the backend, the failure response falls back to the generic Expensify Cards rejection message.
What changes do you think we should make in order to solve the problem?
In src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx:
- Expand the offline blocker guard to include
isBlockedByTravelBilling, and renamehasDeleteWorkspaceExpensifyCardsErrorto a descriptive name such ashasDeleteWorkspaceBlockerError. - Update all references to the guard variable in
continueDeleteWorkspace()and the pre-deletionuseEffecthook.
diff --git a/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx b/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx
--- a/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx
+++ b/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx
@@ -119,8 +119,8 @@ function DeleteWorkspaceFlow({policyID, onDismiss, onDeleteComplete}: DeleteWo
const isBlockedByExpensifyCards = hasExpensifyCardsEnabledOnWorkspace && hasExpensifyCards;
const isBlockedByTravelBilling = hasTravelBillingEnabledOnWorkspace && hasTravelCards;
- // While offline we can't get the real rejection reason from the backend, so if we already know locally that the workspace has active Expensify Cards, block the delete up front instead of queuing one that will fail on reconnect.
- const hasDeleteWorkspaceExpensifyCardsError = isBlockedByExpensifyCards && !!isOffline;
+ // While offline we can't get the real rejection reason from the backend, so if we already know locally that the workspace has active Expensify Cards or Consolidated Travel Billing, block the delete up front instead of queuing one that will fail on reconnect.
+ const hasDeleteWorkspaceBlockerError = (isBlockedByExpensifyCards || isBlockedByTravelBilling) && !!isOffline;
const policyLatestErrorMessage = getLatestErrorMessage(policy);
const isPendingDelete = isPendingDeletePolicy(policy);
@@ -190,7 +190,7 @@ function DeleteWorkspaceFlow({policyID, onDismiss, onDeleteComplete}: DeleteWo
confirmText: translate('common.delete'),
cancelText: translate('common.cancel'),
buttonVariant: CONST.BUTTON_VARIANT.DANGER,
- ...(hasDeleteWorkspaceExpensifyCardsError ? {} : {isConfirmLoading: isPendingDelete}),
+ ...(hasDeleteWorkspaceBlockerError ? {} : {isConfirmLoading: isPendingDelete}),
}).then((result) => {
if (!policyName || result.action !== ModalActions.CONFIRM) {
onDismiss();
@@ -235,7 +235,7 @@ function DeleteWorkspaceFlow({policyID, onDismiss, onDeleteComplete}: DeleteWo
useEffect(() => {
if (isLoadingData) {
return;
}
- if (hasDeleteWorkspaceExpensifyCardsError) {
+ if (hasDeleteWorkspaceBlockerError) {
showDeleteWorkspaceErrorModal();
return;
}
@@ -255,7 +255,7 @@ function DeleteWorkspaceFlow({policyID, onDismiss, onDeleteComplete}: DeleteWo
- }, [isLoadingData, hasDeleteWorkspaceExpensifyCardsError, ...]);
+ }, [isLoadingData, hasDeleteWorkspaceBlockerError, ...]);
When offline with Consolidated Travel Billing active, hasDeleteWorkspaceBlockerError evaluates to true. On mount, DeleteWorkspaceFlow immediately invokes showDeleteWorkspaceErrorModal(), which evaluates isBlockedByExpensifyCards ? ... : ...deleteTravelBillingError and correctly renders the warning "Your company still has Consolidated Travel Billing enabled." without allowing an invalid optimistic deletion.
Differentiators from Competitor Proposals:
- Existing proposals cite non-existent/hallucinated identifiers like
isBlockedByTravelInvoicing(the actual variable insrc/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsxisisBlockedByTravelBilling). - Completely cleans up the legacy identifier
hasDeleteWorkspaceExpensifyCardsErroracross all call sites (continueDeleteWorkspace, the pre-deletion checkuseEffect, and its dependency array), preventing future maintainers from missing Travel Billing dependencies.
What alternative solutions did you explore? (Optional)
- Blocking deletion up front unconditionally (both online and offline): We could block deletion before showing the confirmation modal in both online and offline modes whenever
isBlockedByExpensifyCards || isBlockedByTravelBilling. However, keeping the check scoped to!!isOfflinealigns with the existing architecture ofDeleteWorkspaceFlow.tsx, where online deletions defer authoritative business rule validation and error messages to the backend API response lifecycle. - Handling failure solely on reconnect: Allowing the optimistic deletion offline and relying purely on backend rejection on reconnect causes severe UX degradation: the workspace disappears optimistically, reappears upon reconnecting with an error banner, and shows an inaccurate error message due to backend card feed shared infrastructure. The offline pre-flight guard is the intended pattern in this component.
🚨 Edited by proposal-police: This proposal was edited at 2026-11-11 15:37:36 UTC.
Proposal
Updated to cover @allgandalf's note (domain-funded deletes go through, so they must not be blocked offline) and the Melvin review (carry the blocker key, validate fund linkage and loading readiness). My first version only widened the guard; point 2 below explains why that alone is not enough.
Please re-state the problem that we are trying to solve in this issue.
Deleting a workspace that has Consolidated Travel Billing (CTB) enabled while offline shows no warning and optimistically deletes it. Back online the queued delete is rejected and the row shows "Your company still has Expensify Cards" instead of the CTB warning.
What is the root cause of that problem?
-
The offline pre-flight guard only looks at Expensify Cards. So a CTB-only workspace takes the normal offline path: the delete is queued and the flow unmounts. On reconnect the server rejects it and the server's own wording lands on the workspace row, because the flow that would swap the copy is gone.
https://github.com/Expensify/App/blob/6ab21e5700b85f37585e1cd67c21491949f728b1/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L117-L120
https://github.com/Expensify/App/blob/6ab21e5700b85f37585e1cd67c21491949f728b1/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L235-L241
-
isBlockedByTravelBillingcannot be used as the offline signal. It needs a card in the travel feed's cards list. No App action loads that key (this flow is its only real reader), so for the steps in this issue (enable CTB, add bank account, go offline, delete) it isfalse. WritingisBlockedByExpensifyCards || isBlockedByTravelBillingin the guard therefore still queues the delete for the reported workspace.https://github.com/Expensify/App/blob/6ab21e5700b85f37585e1cd67c21491949f728b1/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L90-L93
-
The action hardcodes the Expensify Cards key, so even when the guard fires the row error would say "Expensify Cards".
https://github.com/Expensify/App/blob/6ab21e5700b85f37585e1cd67c21491949f728b1/src/libs/actions/Policy/Policy.ts#L466-L472
-
The flow does not know which fund holds CTB. It reads the workspace account only, while CTB can live on a domain fund that lists the policy. Per @allgandalf,
DeleteWorkspacesucceeds in that case, so it must never be blocked offline.https://github.com/Expensify/App/blob/6ab21e5700b85f37585e1cd67c21491949f728b1/src/hooks/useTravelBillingFundID.ts#L22-L31
What changes do you think we should make in order to solve the problem?
Keep the change inside the offline pre-flight guard. The online path is not touched.
1. Add an offline-only CTB signal: enabled on the workspace's own fund, and not held by a linked domain fund.
The setting is the thing that is reliably in Onyx offline (the admin enabled it on the Travel page), and it is what the server rejects on (#90407: the workspace becomes deletable once the toggle is off).
// Export the existing helper from useTravelBillingFundID.ts (or move it to TravelBillingUtils) and reuse it.
const linkedDomainTravelFundSelector = (cardSettings: OnyxCollection<ExpensifyCardSettings>) => findLinkedTravelBillingFundID(cardSettings, policyID, workspaceAccountID);
const [linkedDomainTravelFundID, linkedDomainTravelFundResult] = useOnyx(ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS, {selector: linkedDomainTravelFundSelector});
// Domain-funded CTB is deletable on the backend, so only the workspace's own fund blocks the offline delete.
const isTravelBillingFundedByWorkspace = hasTravelBillingEnabledOnWorkspace && !linkedDomainTravelFundID;
linkedDomainTravelFundResultis added toisLoadingData, so the flow never opens the confirm modal before the linkage is known (the loading-readiness point from the Melvin review).- I read the linkage directly instead of calling
useTravelBillingFundID, because that hook falls back to the default fund and does not expose its loading state.
2. Replace the boolean with the key of the blocker that applies offline (Expensify Cards first, as today).
// While offline we can't get the real rejection reason from the backend, so if we already know locally that the workspace
// has active Expensify Cards or funds Consolidated Travel Billing, block the delete up front instead of queuing one that will fail on reconnect.
let offlineDeleteBlockerErrorKey: TranslationPaths | undefined;
if (isOffline && isBlockedByExpensifyCards) {
offlineDeleteBlockerErrorKey = 'workspace.common.deleteOpenExpensifyCardsError';
} else if (isOffline && isTravelBillingFundedByWorkspace) {
offlineDeleteBlockerErrorKey = 'workspace.common.deleteTravelBillingError';
}
Use it in the three places the old boolean is used (isConfirmLoading spread, the deleteWorkspace param, the branch after confirm). showDeleteWorkspaceErrorModal already shows the CTB copy when Expensify Cards are not the blocker, so the modal needs no change.
3. deleteWorkspace takes the key and merges that key.
// DeleteWorkspaceActionParams: hasDeleteWorkspaceExpensifyCardsError?: boolean -> offlineDeleteBlockerErrorKey?: TranslationPaths
if (offlineDeleteBlockerErrorKey) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey(offlineDeleteBlockerErrorKey),
});
return;
}
4. Leave the online path exactly as it is.
isBlockedByTravelBilling (setting + real travel card) and the reconnect effect stay unchanged. That rule was agreed with product in #96872 ("travel invoicing enabled and a real travel card"), and the online wording is already tracked in #102614. Online, the key is undefined, the request is sent and the server decides, same as today.
https://github.com/Expensify/App/blob/6ab21e5700b85f37585e1cd67c21491949f728b1/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L291-L298
Behaviour before / after
| Case | Before | After |
|---|---|---|
| CTB on the workspace fund, offline (this issue) | deleted, no warning, wrong error on reconnect | blocked, CTB warning, nothing queued |
| CTB on a domain fund that lists the policy, offline | deleted optimistically | deleted optimistically (unchanged) |
| Expensify Cards with a real card, offline | blocked, cards warning | unchanged |
| Both blockers, offline | blocked, cards warning | unchanged (cards first) |
| No blocker, offline | deleted optimistically | unchanged |
| Any workspace, online | request sent, server decides | unchanged |
Tests I'll add with the PR
tests/actions/PolicyTest.ts:deleteWorkspacewith the CTB key writes the CTB error, leaves the policy not pending delete, and queues noDeleteWorkspacerequest. Same for the cards key.- UI test for
DeleteWorkspaceFlowcovering the first five rows of the table, including a domain fund whoseTRAVEL_USprogram lists the policy while the workspace account still has an enabled program (must not block).
What alternative solutions did you explore? (Optional)
- Only widening the guard to
isBlockedByExpensifyCards || isBlockedByTravelBilling. The travel flag needs a loaded travel card, which the reported workspace does not have locally, so the delete is still queued. - Dropping the travel-card requirement from
isBlockedByTravelBillingitself. That flag also picks the copy after an online rejection, so any rejected delete on a CTB workspace would show the CTB copy. That changes the online rule agreed in #96872 and overlaps #102614, so I kept it out of this fix. - Using
useTravelBillingFundIDand comparing to the workspace account. It works once Onyx is loaded, but the hook's collection read is not part of the flow's loading gate, so a domain-funded workspace could be blocked if the user confirms before it resolves. - Keeping the flow mounted, or rewriting the error in
failureData. The request the server will reject should not be sent at all, and the offline warning would still be missing.
🚨 Edited by proposal-police: This proposal was edited at 2026-11-11 14:57:53 UTC.
Proposal
Edited to correct the domain fund half of this proposal. @allgandalf is right that DeleteWorkspace goes through when travel billing is domain funded, so the guard must not reach those. What stays is the offline guard and the error key. The verification for the no regression point is at the bottom.
What is the root cause of that problem?
DeleteWorkspaceFlow derives two delete blockers side by side, and the online failure handler treats them as equals:
https://github.com/Expensify/App/blob/a02072066e54b4c510c629d1d635f4e514b043bd/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L291-L298
The offline guard is the one place travel billing was left out:
https://github.com/Expensify/App/blob/a02072066e54b4c510c629d1d635f4e514b043bd/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L117-L120
So with Consolidated Travel Billing as the only blocker, confirming offline takes the plain offline branch, the policy is optimistically marked deleted, the flow unmounts and a DeleteWorkspace request is queued.
https://github.com/Expensify/App/blob/a02072066e54b4c510c629d1d635f4e514b043bd/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L235-L241
Nothing shows while offline because the flow is gone before there is anything to show. On reconnect the queued request is rejected and the message that lands on the policy is the server's own, which talks about Expensify Cards because Consolidated Travel Billing is issued as an Expensify Card feed. No App code sets that copy on this path and the flow is long unmounted, so the effect above never runs to substitute the right wording. The warning is only reachable by not queuing the request at all.
And when the guard does fire, the action always merges the Expensify Cards key, so the error under the workspace row would contradict the modal:
https://github.com/Expensify/App/blob/a02072066e54b4c510c629d1d635f4e514b043bd/src/libs/actions/Policy/Policy.ts#L465-L471
What changes do you think we should make in order to solve the problem?
Cover both blockers in the offline guard, and pick the copy once so the modal and the row error cannot disagree:
const blockerErrorKey = isBlockedByExpensifyCards ? 'workspace.common.deleteOpenExpensifyCardsError' : 'workspace.common.deleteTravelBillingError';
const hasDeleteWorkspaceBlockerError = (isBlockedByExpensifyCards || isBlockedByTravelBilling) && !!isOffline;
blockerErrorKey replaces the inline ternary inside showDeleteWorkspaceErrorModal, and hasDeleteWorkspaceBlockerError replaces hasDeleteWorkspaceExpensifyCardsError at the confirm branch and in the isConfirmLoading spread. Confirming offline then goes down the existing early path, which shows the warning and queues nothing.
Then hand the action that key instead of a boolean, so the error merged onto the policy is the one the user was just shown. DeleteWorkspaceActionParams takes deleteWorkspaceBlockerErrorKey?: TranslationPaths, the flow passes hasDeleteWorkspaceBlockerError ? blockerErrorKey : undefined, and the guard becomes:
if (deleteWorkspaceBlockerErrorKey) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey(deleteWorkspaceBlockerErrorKey),
});
return;
}
isBlockedByTravelBilling keeps reading off policy.policyAccountID, which is what keeps this narrow. Travel billing held on a domain fund leaves those two keys empty, the flag stays false and the delete is untouched online and offline, which matches the delete succeeding on the backend.
What alternative solutions did you explore?
Resolving the fund with useTravelBillingFundID so travel billing on a domain fund blocks the delete too. That was in the first version of this proposal and it is wrong. That delete is accepted, so blocking it would take away a delete that works today. Keying the blocker off policy.policyAccountID is what holds the guard to the case the backend rejects.
Blocking on hasTravelBillingEnabledOnWorkspace alone and dropping the hasTravelCards half. It reads closer to the copy, but it widens the block to workspaces that turned the feature on and never had a card provisioned, which is a separate behaviour change and more than this issue asks for.
Keeping the flow mounted after an offline delete so it can correct the copy when the rejection arrives. The queued delete still fails on the server, the wording it returns is not something the App can rewrite, and the user spends the whole offline period believing the workspace is gone.
Rewriting the policy error in failureData when local state says travel billing is the blocker. That patches over a request that should never have been sent, and still leaves the offline warning missing.
Verification
Five cases against the flow, before and after the change:
| Case | Before | After |
|---|---|---|
| Expensify Cards only, offline | blocked, cards copy | blocked, cards copy |
| Travel billing on the workspace account, offline | deleted, no warning | blocked, travel billing copy |
| Travel billing on a domain fund, offline | deleted, no warning | deleted, no warning |
| No blocker, offline | deleted | deleted |
| Travel billing, online | request sent | request sent |
Only row two moves. Rows three and five are the ones that answer the no regression question: a domain funded workspace still deletes, and online still belongs to the backend.
Recordings of the offline delete, before and after the change:
Offline delete with travel billing as the only blocker, before the change. The workspace is deleted with no warning:
https://github.com/user-attachments/assets/f8b67f73-31c3-4167-95d5-7e8be118bb25
The same flow after the change. The warning shows and the workspace is left intact:
https://github.com/user-attachments/assets/a53fc5a9-6834-4368-8415-53f5f1786481
Proposal
What is the root cause of that problem?
The offline pre-flight guard in DeleteWorkspaceFlow only checks the Expensify Cards blocker, not isBlockedByTravelBilling:
https://github.com/Expensify/App/blob/01f9abd60efeae5a32b016fefde66746a1d4c486/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L114-L120
So when Consolidated Travel Billing is the only blocker, confirming offline queues DeleteWorkspace and unmounts the flow, and no warning is shown:
https://github.com/Expensify/App/blob/01f9abd60efeae5a32b016fefde66746a1d4c486/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L235-L241
On reconnect the server rejects it. The flow that would swap in the Travel Billing copy is gone, so the row shows the server's error ("still has Expensify Cards"):
https://github.com/Expensify/App/blob/01f9abd60efeae5a32b016fefde66746a1d4c486/src/pages/workspace/WorkspacesListPage.tsx#L152-L158
The guard's own write is cards-only too:
https://github.com/Expensify/App/blob/01f9abd60efeae5a32b016fefde66746a1d4c486/src/libs/actions/Policy/Policy.ts#L465-L471
The travel settings and cards are also read from policy.policyAccountID, but since #105095 the Travel page resolves the fund with useTravelBillingFundID, which prefers a domain fund that lists the policy. A feed on the domain is missed:
https://github.com/Expensify/App/blob/01f9abd60efeae5a32b016fefde66746a1d4c486/src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx#L90-L93
What changes do you think we should make in order to solve the problem?
Read the fund with useTravelBillingFundID, counted only when it is the workspace's own or lists the policy (the hook otherwise falls back to the default card fund). Pass the blocker's message key instead of a boolean, Expensify Cards first:
-import {filterInactiveCards, getCardSettings, isCard} from '@libs/CardUtils';
+import {..., isPolicyIDInLinkedExpensifyCardPolicyList} from '@libs/CardUtils';
+const travelBillingFundID = useTravelBillingFundID(policyID);
-const [travelCardsList, travelCardsListResult] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${getTravelBillingFeedID(workspaceAccountID)}`, {
+...getTravelBillingFeedID(travelBillingFundID)}`, {
-const [travelCardSettings, travelCardSettingsResult] = useOnyx(getTravelBillingCardSettingsKey(workspaceAccountID));
+...useOnyx(getTravelBillingCardSettingsKey(travelBillingFundID));
-const hasTravelBillingEnabledOnWorkspace = getIsTravelBillingEnabled(getCardSettings(travelCardSettings, CONST.TRAVEL.PROGRAM_TRAVEL_US));
+const hasTravelBillingEnabledOnWorkspace = getIsTravelBillingEnabled(...) &&
+ (travelBillingFundID === workspaceAccountID || isPolicyIDInLinkedExpensifyCardPolicyList(travelCardSettings?.[CONST.TRAVEL.PROGRAM_TRAVEL_US]?.linkedPolicyIDs, policyID));
+const deleteWorkspaceBlockedErrorKey = isBlockedByExpensifyCards ? 'workspace.common.deleteOpenExpensifyCardsError' : 'workspace.common.deleteTravelBillingError';
-const hasDeleteWorkspaceExpensifyCardsError = isBlockedByExpensifyCards && !!isOffline;
+const offlineDeleteWorkspaceErrorKey = isOffline && (isBlockedByExpensifyCards || isBlockedByTravelBilling) ? deleteWorkspaceBlockedErrorKey : undefined;
-html={translate(isBlockedByExpensifyCards ? 'workspace.common.deleteOpenExpensifyCardsError' : 'workspace.common.deleteTravelBillingError')}
+html={translate(deleteWorkspaceBlockedErrorKey)}
-...(hasDeleteWorkspaceExpensifyCardsError ? {} : {isConfirmLoading: isPendingDelete}),
+...(offlineDeleteWorkspaceErrorKey ? {} : {isConfirmLoading: isPendingDelete}),
-hasDeleteWorkspaceExpensifyCardsError,
+offlineDeleteWorkspaceErrorKey,
-if (hasDeleteWorkspaceExpensifyCardsError) {
+if (offlineDeleteWorkspaceErrorKey) {
@@ Policy.ts @@
-hasDeleteWorkspaceExpensifyCardsError?: boolean;
+offlineDeleteWorkspaceErrorKey?: 'workspace.common.deleteOpenExpensifyCardsError' | 'workspace.common.deleteTravelBillingError';
-errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.common.deleteOpenExpensifyCardsError'),
+errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey(offlineDeleteWorkspaceErrorKey),
Online, the key is undefined, so nothing changes there.
I ran the issue's steps with this fix on dev web and the Android emulator, with Travel Billing seeded on a workspace I own (its own fund, then a domain fund that lists it). Offline, Delete shows "Your company still has Consolidated Travel Billing enabled." and queues nothing. Back online, the workspace stays with no Expensify Cards error.
I'll add a unit test in PolicyTest.ts that calls deleteWorkspace with the Travel Billing key. It expects that sentence in policy.errors and no request, where main always writes the Expensify Cards one. The existing deleteWorkspace tests don't use the old boolean.
What alternative solutions did you explore? (Optional)
- Widening the boolean only: the row behind the modal still says "still has Expensify Cards".
- The hook without the listed-policy check: a domain fund with Travel Billing for another workspace blocks this one.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a workspace has Consolidated Travel Billing enabled (with a linked bank account and active travel cards) and the user deletes the workspace while offline:
- No blocker warning modal ("Your company still has Consolidated Travel Billing enabled.") is shown; instead, the workspace is optimistically deleted and the deletion flow immediately unmounts.
- When the user reconnects online, the queued deletion request is rejected by the backend, and the workspace displays the incorrect error message: "Your company still has Expensify Cards" instead of "Your company still has Consolidated Travel Billing enabled."
What is the root cause of that problem?
The issue consists of two distinct parts across DeleteWorkspaceFlow.tsx and src/libs/actions/Policy/Policy.ts:
-
Part A — Why the Consolidated Travel Billing warning is not shown offline: In
DeleteWorkspaceFlow.tsx, two blockers are derived locally from Onyx state:isBlockedByExpensifyCards = hasExpensifyCardsEnabledOnWorkspace && hasExpensifyCards;isBlockedByTravelBilling = hasTravelBillingEnabledOnWorkspace && hasTravelCards;
However, the offline pre-flight guard at line 120 only checks
isBlockedByExpensifyCards:// While offline we can't get the real rejection reason from the backend, so if we already know locally that the workspace has active Expensify Cards, block the delete up front instead of queuing one that will fail on reconnect. const hasDeleteWorkspaceExpensifyCardsError = isBlockedByExpensifyCards && !!isOffline;When a workspace is only blocked by Consolidated Travel Billing while offline,
hasDeleteWorkspaceExpensifyCardsErrorremainsfalse. As a result, confirming deletion at lines 209–241 does not enter the early-error branch (if (hasDeleteWorkspaceExpensifyCardsError)). Instead, it callsdeleteWorkspace(...)withhasDeleteWorkspaceExpensifyCardsError: false, sets the policy's pending action to delete optimistically, queuesAPI.write(WRITE_COMMANDS.DELETE_WORKSPACE)into Onyx persisted requests, and enters theelse if (isOffline)branch:closeModal(); onDeleteComplete?.(); onDismiss();DeleteWorkspaceFlowunmounts immediately, so no warning modal is ever shown to the user while offline. -
Part B — Why reconnecting online displays the wrong warning ("Your company still has Expensify Cards"):
- Backend rejection: Consolidated Travel Billing cards are issued on the Expensify Card infrastructure under the
TRAVEL_USprogram (CONST.TRAVEL.PROGRAM_TRAVEL_USsharing the same card bank). When the app reconnects online and the queuedDeleteWorkspaceAPI request is processed, the backend rejects the deletion because the policy still has active cards. The backend returns a generic Expensify Cards rejection message. - Unmounted client error handler: In an online deletion flow,
DeleteWorkspaceFlowremains mounted while the request is pending. ItsuseEffectat lines 275–298 intercepts the server error (if (isBlockedByExpensifyCards || isBlockedByTravelBilling)) and maps it toshowDeleteWorkspaceErrorModal(), which displaysworkspace.common.deleteTravelBillingError. However, because the offline delete already unmountedDeleteWorkspaceFlowon confirm, this error-mapping effect never runs on reconnect. - Instead, the API failure triggers
failureDatarollback and stores the backend's raw error onpolicy.errors. InWorkspacesListPage.tsx:156, the workspace row renderserrors: policy.errors, surfacing the backend's "Your company still has Expensify Cards" message. - Action hardcoding: Additionally, in
src/libs/actions/Policy/Policy.ts:465-471, the offline guard currently hardcodes'workspace.common.deleteOpenExpensifyCardsError'intopolicy.errors. If the guard were triggered without passing the specific translation key,policy.errorswould still display the wrong Expensify Cards message under the workspace list row.
- Backend rejection: Consolidated Travel Billing cards are issued on the Expensify Card infrastructure under the
-
Secondary Root Cause — Incomplete fund resolution for Travel Billing: In
DeleteWorkspaceFlow.tsx:90-93,travelCardsListandtravelCardSettingsare queried directly usingworkspaceAccountID. However, across modern Expensify (such as inWorkspaceTravelBillingSection.tsx), Consolidated Travel Billing can be configured on a shared domain fund rather than the individual workspace account. If a workspace's travel billing is configured on a domain fund, reading offworkspaceAccountIDmisses the travel settings and cards entirely (isBlockedByTravelBillingevaluates tofalse). UsinguseTravelBillingFundID(policyID)and verifying(travelBillingFundID === workspaceAccountID || isPolicyIDInLinkedExpensifyCardPolicyList(...))ensures accurate blocker resolution across both workspace-level and domain-level funds without false positives.
What changes do you think we should make in order to solve the problem?
-
Resolve Travel Billing via
useTravelBillingFundIDinDeleteWorkspaceFlow.tsx: UseuseTravelBillingFundID(policyID)to querytravelCardsListandtravelCardSettings, and check whether the workspace is the fund owner or is included inlinkedPolicyIDs:const travelBillingFundID = useTravelBillingFundID(policyID); const [travelCardsList, travelCardsListResult] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${getTravelBillingFeedID(travelBillingFundID)}`, { selector: filterInactiveCards, }); const [travelCardSettings, travelCardSettingsResult] = useOnyx(getTravelBillingCardSettingsKey(travelBillingFundID)); const hasTravelBillingEnabledOnWorkspace = getIsTravelBillingEnabled(getCardSettings(travelCardSettings, CONST.TRAVEL.PROGRAM_TRAVEL_US)) && (travelBillingFundID === workspaceAccountID || isPolicyIDInLinkedExpensifyCardPolicyList(travelCardSettings?.[CONST.TRAVEL.PROGRAM_TRAVEL_US]?.linkedPolicyIDs, policyID)); -
Expand the offline pre-flight guard and derive the specific blocker translation key: Replace the single boolean with the appropriate
TranslationPathskey (retaining the existing priority where Expensify Cards take precedence if both apply):const deleteWorkspaceBlockedErrorKey = isBlockedByExpensifyCards ? 'workspace.common.deleteOpenExpensifyCardsError' : isBlockedByTravelBilling ? 'workspace.common.deleteTravelBillingError' : undefined; // While offline we can't get the real rejection reason from the backend, so if we already know locally that the workspace has active Expensify Cards or Consolidated Travel Billing, block the delete up front instead of queuing one that will fail on reconnect. const offlineDeleteWorkspaceErrorKey = isOffline ? deleteWorkspaceBlockedErrorKey : undefined; const hasDeleteWorkspaceBlockerError = !!offlineDeleteWorkspaceErrorKey; -
Update modal copy and confirmation handling in
DeleteWorkspaceFlow.tsx:- In
showDeleteWorkspaceErrorModal, rendertranslate(deleteWorkspaceBlockedErrorKey ?? 'workspace.common.deleteOpenExpensifyCardsError'). - In
continueDeleteWorkspace, pass...(hasDeleteWorkspaceBlockerError ? {} : {isConfirmLoading: isPendingDelete}). - When confirmed, pass
offlineDeleteWorkspaceErrorKeytodeleteWorkspace(...). - If
hasDeleteWorkspaceBlockerErroristrue, immediately callshowDeleteWorkspaceErrorModal(). The workspace remains intact, and no doomed deletion request is queued.
- In
-
Update
deleteWorkspaceinsrc/libs/actions/Policy/Policy.ts: InDeleteWorkspaceActionParams, replacehasDeleteWorkspaceExpensifyCardsError?: booleanwithofflineDeleteWorkspaceErrorKey?: TranslationPaths. IndeleteWorkspace, merge the specific translation key intopolicy.errorsbefore returning early:// Offline pre-flight guard: we already know locally the workspace has active Expensify Cards or Consolidated Travel Billing, so surface the specific error instead of queuing a delete that the backend will reject on reconnect. if (offlineDeleteWorkspaceErrorKey) { Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey(offlineDeleteWorkspaceErrorKey), }); return; }
With these changes:
- When offline, attempting to delete a workspace with Consolidated Travel Billing immediately surfaces the modal warning "Your company still has Consolidated Travel Billing enabled."
- The
DeleteWorkspaceAPI request is never queued while offline, so reconnecting online does not trigger a server rejection or display the misleading "Your company still has Expensify Cards" error.
What alternative solutions did you explore? (Optional)
- Keeping
DeleteWorkspaceFlowmounted during offline deletion and waiting for reconnect: Rejected because offline deletions are designed to be optimistic and immediately unmount. Forcing the flow to remain mounted across an arbitrary offline period degrades the user experience and violates the app's offline-first paradigm. - Rewriting
policy.errorsinsidefailureDatainPolicy.ts: Rejected because it only patches over a failed request that should never have been dispatched in the first place, and it still fails to show the warning modal to the user when they delete while offline.
Proposal
What is the root cause of that problem?
In src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx, the component determines whether workspace deletion is blocked by existing Expensify cards (isBlockedByExpensifyCards = hasExpensifyCardsEnabledOnWorkspace && hasExpensifyCards) or by Consolidated Travel Billing (isBlockedByTravelBilling = hasTravelBillingEnabledOnWorkspace && hasTravelCards) at lines 117–118.
However, at line 120, the offline pre-flight guard variable is defined as:
const hasDeleteWorkspaceExpensifyCardsError = isBlockedByExpensifyCards && !!isOffline;
This check only considers isBlockedByExpensifyCards and completely omits isBlockedByTravelBilling.
When a user deletes a workspace while offline that has Consolidated Travel Billing enabled (and travel cards linked):
isBlockedByTravelBillingistrue, butisBlockedByExpensifyCardsisfalse, sohasDeleteWorkspaceExpensifyCardsErrorevaluates tofalse.- Inside
continueDeleteWorkspace(lines 208, 230–235),deleteWorkspaceis called withhasDeleteWorkspaceExpensifyCardsError: false. - In
src/libs/actions/Policy/Policy.ts(lines 462–468), the offline pre-flight guard checksif (hasDeleteWorkspaceExpensifyCardsError). Because it isfalse, the early return is bypassed, andPolicy.tsoptimistically marks the policy for deletion while enqueuing anAPI.write(SIDE_EFFECT_REQUEST_COMMANDS.DELETE_WORKSPACE, ...)network request to the offline queue—even though the client already knows locally that this deletion will be rejected by backend business logic upon reconnect. - Back in
DeleteWorkspaceFlow.tsxlines 235–241:
Becauseif (hasDeleteWorkspaceExpensifyCardsError) { showDeleteWorkspaceErrorModal(); } else if (isOffline) { closeModal(); onDeleteComplete?.(); onDismiss(); }hasDeleteWorkspaceExpensifyCardsErrorisfalse,showDeleteWorkspaceErrorModal()is bypassed. Instead, theelse if (isOffline)branch executes, closing the modal and dismissing the flow. - The user is returned to the workspace list with no warning, believing the workspace has been queued for deletion. Only after the client reconnects online does the queued backend request fail and trigger
showDeleteWorkspaceErrorModal()via the post-reconnectuseEffect(line 292).
What changes do you think we should make in order to solve the problem?
We should generalize the offline pre-flight check in both DeleteWorkspaceFlow.tsx and Policy.ts so that all card-related blockers (both Expensify Cards and Consolidated Travel Billing) prevent offline deletion and immediately display the warning modal.
-
In
src/pages/workspace/deleteWorkspace/DeleteWorkspaceFlow.tsx:- Replace the narrow
hasDeleteWorkspaceExpensifyCardsErrorcheck with a generalized card blocker check and derive the appropriate translation key:- Check whether deletion is blocked:
const isBlockedByCards = isBlockedByExpensifyCards || isBlockedByTravelBilling; - Define the offline blocker boolean:
const hasDeleteWorkspaceBlockedError = isBlockedByCards && !!isOffline; - Derive the error translation key:
(Note: Expensify Cards takes precedence if both apply, matching line 150).const blockedDeleteWorkspaceErrorKey: TranslationPaths | undefined = isBlockedByCards ? (isBlockedByExpensifyCards ? 'workspace.common.deleteOpenExpensifyCardsError' : 'workspace.common.deleteTravelBillingError') : undefined;
- Check whether deletion is blocked:
- In
showDeleteWorkspaceErrorModal(line 150), pass the derivedblockedDeleteWorkspaceErrorKeytotranslate(...)inRenderHTML. - In
continueDeleteWorkspace:- At line 208, update the confirm modal loading state guard to check
hasDeleteWorkspaceBlockedErrorinstead ofhasDeleteWorkspaceExpensifyCardsError. - Pass
blockedDeleteWorkspaceErrorKey: hasDeleteWorkspaceBlockedError ? blockedDeleteWorkspaceErrorKey : undefinedintodeleteWorkspace(...). - At line 235, update the branching condition from
if (hasDeleteWorkspaceExpensifyCardsError)toif (hasDeleteWorkspaceBlockedError). When true,showDeleteWorkspaceErrorModal()is immediately presented to the user offline, andcloseModal()/onDismiss()is prevented.
- At line 208, update the confirm modal loading state guard to check
- Replace the narrow
-
In
src/libs/actions/Policy/Policy.ts:- In
DeleteWorkspaceActionParams(lines 425–432), addblockedDeleteWorkspaceErrorKey?: TranslationPaths(while keepinghasDeleteWorkspaceExpensifyCardsErrorfor backward compatibility). - In
deleteWorkspace(lines 462–468), update the offline pre-flight guard: IfblockedDeleteWorkspaceErrorKey(orhasDeleteWorkspaceExpensifyCardsError) is provided, merge the error into Onyx:
This ensures no doomedOnyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey(blockedDeleteWorkspaceErrorKey ?? 'workspace.common.deleteOpenExpensifyCardsError'), }); return;DELETE_WORKSPACErequest is queued toAPI.writewhen the workspace is blocked offline by either Expensify Cards or Consolidated Travel Billing.
- In
Automated Test Plan
- Test File:
tests/actions/PolicyTest.ts - Mock Setup: Seed Onyx with a test policy, mock
travelCardSettingswithCONST.TRAVEL.PROGRAM_TRAVEL_USenabled, and seedtravelCardsListwith an active card. - Given / When / Then Test Cases:
// Givena workspace with Consolidated Travel Billing and travel cards enabled, and offline mode active (blockedDeleteWorkspaceErrorKey = 'workspace.common.deleteTravelBillingError')// WhenPolicy.deleteWorkspaceis executed withblockedDeleteWorkspaceErrorKey: 'workspace.common.deleteTravelBillingError'// Thenpolicy.pendingActionremains null,policy.errorscontains the microsecond error with key'workspace.common.deleteTravelBillingError', andAPI.writeis NOT invoked.// Givena workspace having both Expensify Cards and Consolidated Travel Billing// Whenevaluating the blocker translation key// Then'workspace.common.deleteOpenExpensifyCardsError'is selected, verifying proper blocker precedence.
What alternative solutions did you explore? (Optional)
-
Allow deletion to queue offline and rely on backend rejection after reconnecting:
- We explored letting the deletion proceed offline and waiting for the reconnect
useEffectinDeleteWorkspaceFlow.tsxto handle the error returned by the server. - We rejected this approach because queuing an API request that the client already knows with certainty will fail violates Expensify's offline-first architecture. It optimistically removes the workspace from the UI only to restore it with an error banner upon reconnecting, causing a confusing user experience.
- We explored letting the deletion proceed offline and waiting for the reconnect
-
Prevent the confirmation dialog from opening when blocked offline:
- We explored showing the error modal immediately upon tapping "Delete workspace" without showing the initial confirmation dialog.
- We rejected this approach because the online deletion flow validates card blockers within the confirmation modal flow (consistent with
calculateBillNewDotand outstanding balance checks). Keeping the offline flow aligned with the online flow preserves consistent UX across network states.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~010d8d25cfc1ba4cf3
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
@cretadn22 I'd like to work on this if it remains open to new proposals. Before submitting a solution, I need to independently reproduce the reported flow, which requires an expensifail account with Consolidated Travel Billing and a linked bank account.
Could you confirm the supported test setup for external contributors: is it acceptable to seed Travel Billing settings and card data locally on a workspace we own, or is a UI-provisioned staging fixture required? I would cover both workspace-owned and linked-domain funds, including an unrelated workspace as a negative control.
I've reviewed the existing proposals and traced DeleteWorkspaceFlow and useTravelBillingFundID on main (089b2c5ea8147b2fed0d448bfa3a7f334195e0aa). I haven't reproduced the full flow or completed cross-platform testing yet. This is an investigation/availability request; I will submit a proposal only after reproduction and only if I can establish a meaningfully different solution.
📣 @songconmaisaix31-design! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
@MelvinBot Investigate this issue