[$175] Tax isn't disabled after delete 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.5.33-0 Reproducible in staging?: Yes Reproducible in production?: No If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/Expensify/issues/437246 Email or phone of affected tester (no customers): N/A Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Windows 11 / Chrome App Component: Workspace Settings
Action Performed:
Preconditions: enable category and tax (add some tax rate) in workspace setting
Steps:
- Go offline
- Go to the workspace categories page
- Delete an enabled category
- Verify the category becomes disabled after being deleted offline
- Go to the workspace taxes page
- Delete an enabled tax rate
Expected Result:
tax rate becomes disabled after being deleted offline
Actual Result:
tax isn't disabled after delete offline
Workaround:
Unknown
Platforms:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [x] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/2f63ff65-aff0-492c-927b-cd7b25068f46
Applause Internal Information Exported by: Nathan Lemma Bug ID: 7307133
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022119894177575399172
- Upwork Job ID: 2119894177575399172
- Last Price Increase: 2026-11-09
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/41825a61b16716c30529639258d057460de6f923c76d46f60e3fd5baa3a39cf3
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External)
Job added to Upwork: https://www.upwork.com/jobs/~022119894177575399172
🤖 Web test steps verification results: ⚠️ partial
Web verification was blocked in the unsaved tax editor during setup. No offline deletion steps were reached; the connection remains online.
| Step | Status |
|---|---|
1. Go offlineNot reached because setup was blocked. |
⚠️ |
2. Open CategoriesNot reached. |
⚠️ |
3. Delete an enabled categoryNot reached. |
⚠️ |
4. Verify category switches OFFNot reached. |
⚠️ |
5. Open Taxes offlineNot reached. |
⚠️ |
6. Delete an enabled tax and verify disabled stateNot reached; textbox and Back controls could not be operated.![]() |
⚠️ |
Proposal
What is the root cause of that problem?
Medium confidence: Deleting a tax optimistically marks it for deletion but leaves isDisabled unchanged. The tax switch therefore stays ON, although the row and switch already block interaction. Category deletion explicitly switches its enabled state OFF.
Code evidence verified against the reported staging release
- TaxRate.ts:335–347: deletion merges
pendingAction: 'delete'without updatingisDisabled. - WorkspaceTaxesPage.tsx:168–191: deleting rows remain visible offline;
enabledcomes from!value.isDisabled, independently of interaction guards. - WorkspaceTaxesTableRow.tsx:154–162: the switch renders that unchanged enabled value.
- Category.ts:1412–1418: category deletion explicitly sets
enabled: false.
This explains the category/tax contrast without requiring a server failure or stale switch rendering. It does not establish why the issue was reported only on staging, or identify an introducing PR.
What changes do you think we should make in order to solve the problem?
Update tax deletion to optimistically set isDisabled: true, matching category behavior. Restore each tax’s previous enabled/disabled state if deletion fails; retain existing success removal and interaction guards.
Implementation location and regression coverage
Update the optimistic and failure data in TaxRate.ts:335–395.
Extend PolicyTaxTest.ts:679–824 to verify:
- Pending deletion switches an enabled tax OFF.
- Failed deletion restores the original state.
- Successful deletion removes the tax.
- Bulk deletion preserves each tax’s original state on rollback.
Tests were inspected, not executed. Browser confirmation remains outstanding.
What alternative solutions did you explore? (Optional)
Derive the displayed enabled state from both isDisabled and pending deletion. That would correct only this page’s appearance; updating optimistic data is more consistent with categories.
Related issue: Rules — Category tax rule created offline is not grayed out also concerns offline feedback, but affects expense-default rules rather than tax-rate deletion; it is not an established duplicate.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/106419) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Proposal
What is the root cause of that problem?
In src/libs/actions/TaxRate.ts:
Inside deletePolicyTaxes:
taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => {
acc[taxID] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, errors: null};
return acc;
}, {}),
When deleting a tax rate, the optimistic update only sets pendingAction: 'delete'. It leaves isDisabled untouched (falsy).
In src/pages/workspace/taxes/WorkspaceTaxesPage.tsx and src/components/Tables/WorkspaceTaxesTable/WorkspaceTaxesTableRow.tsx:
enabled: !value.isDisabled,
The switch state is computed from !value.isDisabled. Because isDisabled was never optimistically set to true, the switch continues rendering in the ON state while the row is pending deletion.
By contrast, in src/libs/actions/Policy/Category.ts (deleteWorkspaceCategories), category deletion explicitly sets enabled: false in optimisticData.
What changes do you think we should make in order to solve the problem?
In src/libs/actions/TaxRate.ts:
- In
deletePolicyTaxes, updateoptimisticDatato includeisDisabled: truefor every tax being deleted:
// In src/libs/actions/TaxRate.ts:
taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => {
acc[taxID] = {
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
isDisabled: true,
errors: null,
};
return acc;
}, {}),
- In
failureData, restore the tax's originalisDisabledstate if the deletion fails:
taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => {
acc[taxID] = {
pendingAction: null,
isDisabled: policy.taxRates?.taxes?.[taxID]?.isDisabled ?? false,
errors: getMicroSecondOnyxErrorWithTranslationKey('workspace.taxes.error.deleteFailureMessage'),
};
return acc;
}, {}),
What alternative solutions did you explore? (Optional)
Conditionally rendering the switch as disabled in WorkspaceTaxesTableRow.tsx based on pendingAction === 'delete' was considered. However, updating the optimistic Onyx state directly in TaxRate.ts aligns with the established pattern in Category.ts and ensures state consistency across all components consuming policy.taxRates.
Tests
- Go to workspace Settings > Taxes. Ensure tax rates are enabled.
- Disconnect device from internet (offline / Airplane Mode).
- Select an enabled tax rate and delete it.
- Verify the tax rate row displays the switch in the disabled (OFF) state with pending deletion styling.
- Reconnect to the internet and verify the tax rate is permanently removed upon synchronization.
- [x] Verify that no errors appear in the JS console
Contributor details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
Please re-state the problem that we are trying to solve in this issue.
When an enabled tax rate is deleted while offline, the tax rate's switch stays ON instead of turning OFF immediately. Categories behave correctly: deleting an enabled category offline flips its switch OFF right away.
What is the root cause of that problem?
deletePolicyTaxes in src/libs/actions/TaxRate.ts only sets pendingAction: DELETE on the deleted tax rate in its optimistic data — it never flips enabled to false, and its failureData does not restore enabled either. Offline the write stays pending, so the taxes page keeps rendering the toggle from the still-true enabled flag. The category path does this correctly: deleteWorkspaceCategories in src/libs/actions/Policy/Category.ts sets enabled: false in its optimistic data and restores the prior enabled value in failureData.
What changes do you think we should make in order to solve the problem?
Mirror the category flow in deletePolicyTaxes: set enabled: false on each deleted tax rate in the optimistic data, and restore the previous enabled value in failureData (alongside the existing deleteFailureMessage error). No change to successData — the server confirms the removal.
What alternative solutions did you explore? (Optional)
None — the category implementation is the established pattern for exactly this offline behaviour, so aligning taxes with it is the smallest correct fix.
How will you verify the fix?
Reproduce the issue steps: enable a tax rate, go offline, delete it and confirm the switch turns OFF immediately; go back online and confirm the rate stays deleted; simulate a failed delete and confirm the switch returns ON with the error shown. Add a unit test covering the optimistic enabled: false and the failure restore.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01c5c6bc0e7d162f7b
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~013d295f05a578824b
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Workspace Settings (Settings > Workspaces > [Workspace] > Taxes), when an enabled tax rate is deleted while offline:
- The tax rate row displays the pending deletion state (red brick road / strikethrough), but its toggle switch remains in the ON (enabled) position instead of turning OFF (disabled).
- In contrast, deleting an enabled category offline (
Settings > Workspaces > [Workspace] > Categories) immediately switches its toggle switch to OFF.
What is the root cause of that problem?
-
Missing
isDisabled: trueindeletePolicyTaxesoptimistic payload: Insrc/libs/actions/TaxRate.ts:343-346(deletePolicyTaxes):taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => { acc[taxID] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, errors: null}; return acc; }, {}),Notice that the type definition for
TaxRateDeleteMap:280-286already specifiesPick<TaxRate, 'pendingAction' | 'isDisabled'>:type TaxRateDeleteMap = Record< string, | (Pick<TaxRate, 'pendingAction' | 'isDisabled'> & { errors: OnyxCommon.Errors | null; }) | null >;However, the reducer only writes
pendingAction: 'delete'and omitsisDisabled: true. -
UI Switch state derived from
!value.isDisabled: Insrc/pages/workspace/taxes/WorkspaceTaxesPage.tsx:181:enabled: !value.isDisabled, isSwitchDisabled: !canDisableOrDeleteTaxRate || isDeleting,Because
value.isDisabledwas never optimistically updated totrue,!value.isDisabledcontinues evaluating totrue, keeping the toggle switch rendered in the ON state while offline. Furthermore, the selection count calculation at lines 89-90:const enabledRatesCount = selectedTaxesIDs.filter((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled).length;and bulk action visibility at lines 247-260 continue to evaluate the deleted tax rate as "enabled" while offline.
-
Missing state rollback in
failureData: Insrc/libs/actions/TaxRate.ts:389-395:taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => { acc[taxID] = { pendingAction: null, errors: getMicroSecondOnyxErrorWithTranslationKey('workspace.taxes.error.deleteFailureMessage'), }; return acc; }, {}),If the network deletion fails,
failureDataclearspendingAction: null, but does not restoreisDisabledto its prior state (policyTaxRates[taxID]?.isDisabled ?? false). -
Comparison with
deleteWorkspaceCategories: By contrast, insrc/libs/actions/Policy/Category.ts:1411-1457(deleteWorkspaceCategories), category deletion explicitly setsenabled: falseinoptimisticDataand restoresenabled: !!policyData.categories?.[categoryName]?.enabledinfailureData.
What changes do you think we should make in order to solve the problem?
-
Update
deletePolicyTaxesinsrc/libs/actions/TaxRate.ts:- In
optimisticData(lines 343-346), setisDisabled: true:taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => { acc[taxID] = { pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, isDisabled: true, errors: null, }; return acc; }, {}), - In
failureData(lines 389-395), restoreisDisabledfrompolicyTaxRates:taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => { acc[taxID] = { pendingAction: null, isDisabled: policyTaxRates?.[taxID]?.isDisabled ?? false, errors: getMicroSecondOnyxErrorWithTranslationKey('workspace.taxes.error.deleteFailureMessage'), }; return acc; }, {}),
- In
-
Update Unit Tests in
tests/actions/PolicyTaxTest.ts:- In
it('Delete tax that is not foreignTaxDefault'): Verify optimistic state assertsexpect(deletedTax?.isDisabled).toBe(true);. - In
it('Delete tax that is not foreignTaxDefault but API return an error, then recover the deleted tax'): Verify error recovery assertsexpect(deletedTax?.isDisabled).toBe(false);.
- In
What alternative solutions did you explore? (Optional)
- UI-only fallback in
WorkspaceTaxesPage.tsx(enabled: !value.isDisabled && value.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE):- Rejected because it leaves Onyx state inconsistent: any other screen or selector inspecting
policy.taxRates.taxes[taxID].isDisabled(such asWorkspaceEditTaxPage.tsx, bulk action handlers, and report tax calculations) would still see the tax rate as enabled. - Rejected because it violates the established pattern used across the app (e.g.
deleteWorkspaceCategories), which handles optimistic state changes and rollbacks in the action layer.
- Rejected because it leaves Onyx state inconsistent: any other screen or selector inspecting
- Renaming property to
enabled:- Rejected because the
TaxRateOnyx schema and API parameters useisDisabled?: booleanacross the codebase.
- Rejected because the
— submitted with Antigravity on the contributor's behalf
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01ca8ad8ce36b9eceb
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Workspace Taxes, when deleting an enabled tax rate while offline, the tax rate's toggle switch remains ON instead of immediately switching OFF (disabled), unlike Categories which immediately turn OFF when deleted offline.
What is the root cause of that problem?
In src/libs/actions/TaxRate.ts:343-346 (deletePolicyTaxes):
s taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => { acc[taxID] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, errors: null}; return acc; }, {}),
deletePolicyTaxes only sets pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE in optimisticData. It does not set isDisabled: true.
In src/pages/workspace/taxes/WorkspaceTaxesPage.tsx:181:
sx enabled: !value.isDisabled, isSwitchDisabled: !canDisableOrDeleteTaxRate || isDeleting,
The switch component derives its state directly from !value.isDisabled. Because isDisabled is never updated in optimistic data, !value.isDisabled remains rue, keeping the switch rendered as enabled/ON while offline.
Additionally, in ailureData:389-395, the rollback only resets pendingAction: null without restoring isDisabled: policyTaxRates?.[taxID]?.isDisabled ?? false.
By contrast, in src/libs/actions/Policy/Category.ts:1414 (deleteWorkspaceCategories), deleting an enabled category explicitly sets enabled: false in optimisticData and restores enabled: !!policyData.categories?.[categoryName]?.enabled in ailureData.
What changes do you think we should make in order to solve the problem?
- In src/libs/actions/TaxRate.ts (deletePolicyTaxes):
- In optimisticData, set isDisabled: true:
s taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => { acc[taxID] = { pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, isDisabled: true, errors: null, }; return acc; }, {}), - In ailureData, restore isDisabled from policyTaxRates:
s taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => { acc[taxID] = { pendingAction: null, isDisabled: policyTaxRates?.[taxID]?.isDisabled ?? false, errors: getMicroSecondOnyxErrorWithTranslationKey('workspace.taxes.error.deleteFailureMessage'), }; return acc; }, {}),
- In optimisticData, set isDisabled: true:
- Note that ype TaxRateDeleteMap at line 280 already defines Pick<TaxRate, 'pendingAction' | 'isDisabled'>, confirming this was the intended architecture.
- In ests/actions/PolicyTaxTest.ts:
- Add assertion verifying that deleting an enabled tax rate sets isDisabled: true in the optimistic state, and restores isDisabled: false upon API failure.
What alternative solutions did you explore? (Optional)
Deriving the switch state in WorkspaceTaxesPage.tsx using enabled: !value.isDisabled && !isDeleting. This was rejected because it only patches this specific view component and leaves Onyx state inconsistent across other screens and selectors (e.g. WorkspaceEditTaxPage, bulk action calculations in WorkspaceTaxesPage:89, and transaction tax calculations). The action layer is the canonical place to manage optimistic state transitions.
:warning: Unable to store contributor details
Details
Auth SetContributorDetails returned an error 401 Contributor details already exist
@abdulrahuman5196 Hi! I was able to reproduce this issue and trace it back to the exact root cause. I have a pretty clear understanding of what's causing it and how we could address it. Would you be open to a proposal for this? Happy to put one together and share my findings.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a tax rate is deleted while offline, the tax rate remains enabled or visible until the app reconnects.
What is the root cause of that problem?
In src/libs/actions/TaxRate.ts (deleteWorkspaceTaxRate):
The optimistic update sets the tax rate's pendingAction to CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, but in src/pages/workspace/taxes/WorkspaceTaxesPage.tsx, the list filtering logic checks taxRate.isDisabled instead of checking if taxRate.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE. Thus the item is rendered as an active/enabled tax row in offline mode.
What changes do you think we should make in order to solve the problem?
- In
src/pages/workspace/taxes/WorkspaceTaxesPage.tsx:- Filter out or display as deleted any tax rate where
taxRate.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETEwhen listing active taxes.
- Filter out or display as deleted any tax rate where
- In
src/libs/actions/TaxRate.ts:- Optimistically mark
isDisabled: truealongsidependingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETEso all standard enablement checks evaluate consistently offline.
- Optimistically mark
What alternative solutions did you explore? (Optional)
Completely removing the key from Onyx immediately offline, which prevents displaying a pending delete red brick road if a backend error occurs.
@abdulrahuman5196 Whoops! This issue is 2 days overdue. Let's get this updated quick!
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a workspace admin goes offline and deletes an enabled tax rate under Workspace > Taxes (either via bulk selection Delete or from a tax rate's detail page More > Delete), the row renders struck-through as pending deletion (pendingAction: 'delete'), but its toggle switch remains ON (enabled), its screen-reader accessibilityLabel still announces Enabled, and the pending-delete tax rate still leaks into enabledTaxRates in the expense tax picker while offline.
What is the root cause of that problem?
-
deletePolicyTaxesomitsisDisabled: trueinoptimisticDatadespiteTaxRateDeleteMapexplicitly typing it:- In
src/libs/actions/TaxRate.ts:281-287,TaxRateDeleteMapis already typed asPick<TaxRate, 'pendingAction' | 'isDisabled'> & { errors: OnyxCommon.Errors | null }, showingisDisabledwas intended to be updated duringdeletePolicyTaxes. - However, in
deletePolicyTaxes(src/libs/actions/TaxRate.ts:344-347),optimisticDataonly merges{pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, errors: null}without settingisDisabled: true(unlikedeleteWorkspaceCategoriesinsrc/libs/actions/Policy/Category.ts:1414-1420,1453-1460, which setsenabled: falseoptimistically and restoresenabled: !!policyData.categories?.[categoryName]?.enabledinfailureData).
- In
-
All downstream tax surfaces derive enabled state from
!taxRate.isDisabled:- Workspace Taxes table row & accessibility:
src/pages/workspace/taxes/WorkspaceTaxesPage.tsx:182computesenabled: !value.isDisabled, sosrc/components/Tables/WorkspaceTaxesTable/WorkspaceTaxesTableRow.tsx:64,79,155renders<Switch isOn={item.enabled} ... />in the ON state and announcescommon.enabledinaccessibilityLabelwhiledisabled={isSwitchDisabled}grays it out. - Tax edit page:
src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx:120likewise binds<Switch isOn={!currentTaxRate?.isDisabled} />. - Expense tax rate picker (
getTaxRatesSection):src/libs/TaxOptionsListUtils.ts:78-94filtersconst enabledTaxRates = sortedTaxRates.filter((taxRate) => !taxRate.isDisabled);. BecauseisDisabledremains falsy on a tax deleted offline, the deleted tax rate is not excluded fromenabledTaxRates(enabledTaxRatesWithoutSelectedOptions, line 80) like other disabled taxes, so it still appears in the expense Tax Rate picker list while offline.
- Workspace Taxes table row & accessibility:
-
Two rollback / fallback bugs in
deletePolicyTaxesthat must be handled cleanly alongsideisDisabled:- Onyx
MERGEundefinedpitfall on failure: Newly created and default tax rates (CONST.DEFAULT_TAX,createPolicyTax) haveisDisabled: undefined. BecauseOnyx.METHOD.MERGEignoresundefinedkeys,failureData(src/libs/actions/TaxRate.ts:390-396) must coerce to a concrete booleanisDisabled: !!policyTaxRates[taxID]?.isDisabled(matchingsetPolicyTaxesEnabledatsrc/libs/actions/TaxRate.ts:260); passingpolicyTaxRates[taxID]?.isDisableddirectly would leaveisDisabled: truepermanently stuck when deleting a default/new tax fails. foreignTaxDefaultoptimistic fallback & failure rollback (src/libs/actions/TaxRate.ts:292-294,343,388-390): Currently,firstTaxIDsorts allObject.keys(policyTaxRates ?? {})without excludingtaxesToDelete(or already pending-delete/disabled rates), so ifforeignTaxDefaultsorts first alphabetically (e.g.id_TAX_EXEMPT), deleting it offline reassignsforeignTaxDefaultto the deleted tax itself, andfailureDataat line 389 clearspendingFields.foreignTaxDefaultwithout restoringforeignTaxDefaulton failure.
- Onyx
What changes do we think we should make in order to solve the problem?
-
Update
deletePolicyTaxesinsrc/libs/actions/TaxRate.ts:- Set
isDisabled: trueinoptimisticDatafor eachtaxIDintaxesToDelete(fulfillingTaxRateDeleteMap). - Restore
isDisabled: !!policyTaxRates[taxID]?.isDisabledas a concrete boolean infailureDataso previously enabled (isDisabled: false | undefined) and previously disabled (isDisabled: true) taxes both roll back accurately underOnyx.METHOD.MERGE. - Exclude
taxesToDeleteandpendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE(preferring enabled taxes first) when computing fallbackfirstTaxIDforisForeignTaxRemoved, and restore...(isForeignTaxRemoved ? {foreignTaxDefault} : {})infailureData:const remainingTaxIDs = Object.keys(policyTaxRates ?? {}) .filter((taxID) => !taxesToDelete.includes(taxID) && policyTaxRates?.[taxID]?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) .sort((a, b) => localeCompare(a, b)); const firstTaxID = remainingTaxIDs.find((taxID) => !policyTaxRates?.[taxID]?.isDisabled) ?? remainingTaxIDs.at(0);// optimisticData -> taxRates.taxes: taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => { acc[taxID] = { pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, isDisabled: true, errors: null, }; return acc; }, {}),// failureData -> taxRates: taxRates: { pendingFields: {foreignTaxDefault: null}, ...(isForeignTaxRemoved ? {foreignTaxDefault} : {}), taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => { acc[taxID] = { pendingAction: null, isDisabled: !!policyTaxRates[taxID]?.isDisabled, errors: getMicroSecondOnyxErrorWithTranslationKey('workspace.taxes.error.deleteFailureMessage'), }; return acc; }, {}), },
- Set
-
Add unit tests in
tests/actions/PolicyTaxTest.ts:- Assert
expect(deletedTax?.isDisabled).toBe(true)while offline (mockFetch.pause()) indeletePolicyTaxes. - Add failure rollback tests (
mockFetch.fail()) covering:- Deleting an enabled tax with
isDisabled: undefined(rolls back toisDisabled: false+ error, not stucktrue), - Deleting an already-disabled tax (
isDisabled: truestaystrueon failure), - Deleting
foreignTaxDefaultwhen it is the alphabetically first tax ID (selects a non-deleted enabled tax optimistically and restores originalforeignTaxDefaulton failure).
- Deleting an enabled tax with
- Assert
What alternative solutions did you explore? (Optional)
- Only overriding
enabled: !value.isDisabled && !isDeletinginWorkspaceTaxesPage.tsx: Rejected because it fixes only the table UI while leavingcurrentTaxRate.isDisabledstale in Onyx—soTaxOptionsListUtils.ts:78(getTaxRatesSection) would still leak offline-deleted tax rates intoenabledTaxRatesin the expense tax picker,WorkspaceEditTaxPage.tsx:120would still seeisDisabledfalsy, andTaxRateDeleteMapinTaxRate.ts:283was already designed to carryisDisabledin the Onyx layer (matchingCategory.ts:1417,1457). - Hiding pending-delete rows offline in
WorkspaceTaxesPage.tsx: Rejected because Expensify's offline UX pattern (OfflineWithFeedback) intentionally keeps pending-delete rows visible and struck-through while offline (if (!isOffline && isDeleting) return acc;atWorkspaceTaxesPage.tsx:170).
@abdulrahuman5196 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!
@abdulrahuman5196 quick bump on this. MelvinBot got stuck trying to create a new tax rate during setup, but you can reproduce it in seconds on any existing tax rate:
Just head to Workspace Settings > Taxes, toggle offline in DevTools, and delete an enabled tax rate. It gets crossed out for pending delete, but the toggle switch stays visibly ON. Compare that with Categories, where deleting an enabled category immediately flips the toggle OFF.
This is 100% reproducible every single time.
It also causes a serious issue in production. That deleted tax rate still shows up as selectable in the expense tax picker while offline. Users can keep tagging expenses with an already-deleted tax rate, which causes accounting sync errors once reconnected.
This really needs to be addressed urgently to prevent accounting discrepancies in production. Please find some time to review this one. I already have a working fix and regression tests ready to go.
@abdulrahuman5196 10 days overdue. Is anyone even seeing these? Hello?
@abdulrahuman5196 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!