App icon indicating copy to clipboard operation
App copied to clipboard

[$175] Tax isn't disabled after delete offline

Open applause-bot[bot] opened this issue 3 weeks ago • 22 comments

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:

  1. Go offline
  2. Go to the workspace categories page
  3. Delete an enabled category
  4. Verify the category becomes disabled after being deleted offline
  5. Go to the workspace taxes page
  6. 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

View all open jobs on GitHub

Applause Internal Information Exported by: Nathan Lemma Bug ID: 7307133

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Nov 09 '26 20:11 applause-bot[bot]

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

applause-bot[bot] avatar Nov 09 '26 20:11 applause-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External)

melvin-bot[bot] avatar Nov 09 '26 20:11 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022119894177575399172

melvin-bot[bot] avatar Nov 09 '26 20:11 melvin-bot[bot]

🤖 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.

Tax setup editor where web verification was blocked
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.
Tax setup editor where web verification was blocked
⚠️

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

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.


view run

MelvinBot avatar Nov 09 '26 20:11 MelvinBot

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:

  1. In deletePolicyTaxes, update optimisticData to include isDisabled: true for 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;
}, {}),
  1. In failureData, restore the tax's original isDisabled state 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

  1. Go to workspace Settings > Taxes. Ensure tax rates are enabled.
  2. Disconnect device from internet (offline / Airplane Mode).
  3. Select an enabled tax rate and delete it.
  4. Verify the tax rate row displays the switch in the disabled (OFF) state with pending deletion styling.
  5. 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

kevinjosh10 avatar Nov 09 '26 20:11 kevinjosh10

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 09 '26 20:11 melvin-bot[bot]

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

khizzcr7 avatar Nov 10 '26 00:11 khizzcr7

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 10 '26 00:11 melvin-bot[bot]

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:

  1. 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).
  2. 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?

  1. Missing isDisabled: true in deletePolicyTaxes optimistic payload: In src/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-286 already specifies Pick<TaxRate, 'pendingAction' | 'isDisabled'>:

    type TaxRateDeleteMap = Record<
        string,
        | (Pick<TaxRate, 'pendingAction' | 'isDisabled'> & {
              errors: OnyxCommon.Errors | null;
          })
        | null
    >;
    

    However, the reducer only writes pendingAction: 'delete' and omits isDisabled: true.

  2. UI Switch state derived from !value.isDisabled: In src/pages/workspace/taxes/WorkspaceTaxesPage.tsx:181:

    enabled: !value.isDisabled,
    isSwitchDisabled: !canDisableOrDeleteTaxRate || isDeleting,
    

    Because value.isDisabled was never optimistically updated to true, !value.isDisabled continues evaluating to true, 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.

  3. Missing state rollback in failureData: In src/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, failureData clears pendingAction: null, but does not restore isDisabled to its prior state (policyTaxRates[taxID]?.isDisabled ?? false).

  4. Comparison with deleteWorkspaceCategories: By contrast, in src/libs/actions/Policy/Category.ts:1411-1457 (deleteWorkspaceCategories), category deletion explicitly sets enabled: false in optimisticData and restores enabled: !!policyData.categories?.[categoryName]?.enabled in failureData.

What changes do you think we should make in order to solve the problem?

  1. Update deletePolicyTaxes in src/libs/actions/TaxRate.ts:

    • In optimisticData (lines 343-346), set isDisabled: 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), restore isDisabled from policyTaxRates:
      taxes: taxesToDelete.reduce<TaxRateDeleteMap>((acc, taxID) => {
          acc[taxID] = {
              pendingAction: null,
              isDisabled: policyTaxRates?.[taxID]?.isDisabled ?? false,
              errors: getMicroSecondOnyxErrorWithTranslationKey('workspace.taxes.error.deleteFailureMessage'),
          };
          return acc;
      }, {}),
      
  2. Update Unit Tests in tests/actions/PolicyTaxTest.ts:

    • In it('Delete tax that is not foreignTaxDefault'): Verify optimistic state asserts expect(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 asserts expect(deletedTax?.isDisabled).toBe(false);.

What alternative solutions did you explore? (Optional)

  1. 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 as WorkspaceEditTaxPage.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.
  2. Renaming property to enabled:
    • Rejected because the TaxRate Onyx schema and API parameters use isDisabled?: boolean across the codebase.

— submitted with Antigravity on the contributor's behalf

HindsightWise avatar Nov 10 '26 11:11 HindsightWise

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 10 '26 11:11 melvin-bot[bot]

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?

  1. 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; }, {}),
  2. Note that ype TaxRateDeleteMap at line 280 already defines Pick<TaxRate, 'pendingAction' | 'isDisabled'>, confirming this was the intended architecture.
  3. 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.

jmquero92 avatar Nov 10 '26 12:11 jmquero92

:warning: Unable to store contributor details

Details
Auth SetContributorDetails returned an error
401 Contributor details already exist

melvin-bot[bot] avatar Nov 10 '26 12:11 melvin-bot[bot]

@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.

samithreddychinni avatar Nov 10 '26 16:11 samithreddychinni

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?

  1. 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.DELETE when listing active taxes.
  2. In src/libs/actions/TaxRate.ts:
    • Optimistically mark isDisabled: true alongside pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE so all standard enablement checks evaluate consistently offline.

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.

TassioSales avatar Nov 11 '26 13:11 TassioSales

@abdulrahuman5196 Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar Nov 12 '26 21:11 melvin-bot[bot]

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?

  1. deletePolicyTaxes omits isDisabled: true in optimisticData despite TaxRateDeleteMap explicitly typing it:

    • In src/libs/actions/TaxRate.ts:281-287, TaxRateDeleteMap is already typed as Pick<TaxRate, 'pendingAction' | 'isDisabled'> & { errors: OnyxCommon.Errors | null }, showing isDisabled was intended to be updated during deletePolicyTaxes.
    • However, in deletePolicyTaxes (src/libs/actions/TaxRate.ts:344-347), optimisticData only merges {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, errors: null} without setting isDisabled: true (unlike deleteWorkspaceCategories in src/libs/actions/Policy/Category.ts:1414-1420,1453-1460, which sets enabled: false optimistically and restores enabled: !!policyData.categories?.[categoryName]?.enabled in failureData).
  2. All downstream tax surfaces derive enabled state from !taxRate.isDisabled:

  3. Two rollback / fallback bugs in deletePolicyTaxes that must be handled cleanly alongside isDisabled:

    • Onyx MERGE undefined pitfall on failure: Newly created and default tax rates (CONST.DEFAULT_TAX, createPolicyTax) have isDisabled: undefined. Because Onyx.METHOD.MERGE ignores undefined keys, failureData (src/libs/actions/TaxRate.ts:390-396) must coerce to a concrete boolean isDisabled: !!policyTaxRates[taxID]?.isDisabled (matching setPolicyTaxesEnabled at src/libs/actions/TaxRate.ts:260); passing policyTaxRates[taxID]?.isDisabled directly would leave isDisabled: true permanently stuck when deleting a default/new tax fails.
    • foreignTaxDefault optimistic fallback & failure rollback (src/libs/actions/TaxRate.ts:292-294,343,388-390): Currently, firstTaxID sorts all Object.keys(policyTaxRates ?? {}) without excluding taxesToDelete (or already pending-delete/disabled rates), so if foreignTaxDefault sorts first alphabetically (e.g. id_TAX_EXEMPT), deleting it offline reassigns foreignTaxDefault to the deleted tax itself, and failureData at line 389 clears pendingFields.foreignTaxDefault without restoring foreignTaxDefault on failure.

What changes do we think we should make in order to solve the problem?

  1. Update deletePolicyTaxes in src/libs/actions/TaxRate.ts:

    • Set isDisabled: true in optimisticData for each taxID in taxesToDelete (fulfilling TaxRateDeleteMap).
    • Restore isDisabled: !!policyTaxRates[taxID]?.isDisabled as a concrete boolean in failureData so previously enabled (isDisabled: false | undefined) and previously disabled (isDisabled: true) taxes both roll back accurately under Onyx.METHOD.MERGE.
    • Exclude taxesToDelete and pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE (preferring enabled taxes first) when computing fallback firstTaxID for isForeignTaxRemoved, and restore ...(isForeignTaxRemoved ? {foreignTaxDefault} : {}) in failureData:
      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;
          }, {}),
      },
      
  2. Add unit tests in tests/actions/PolicyTaxTest.ts:

    • Assert expect(deletedTax?.isDisabled).toBe(true) while offline (mockFetch.pause()) in deletePolicyTaxes.
    • Add failure rollback tests (mockFetch.fail()) covering:
      1. Deleting an enabled tax with isDisabled: undefined (rolls back to isDisabled: false + error, not stuck true),
      2. Deleting an already-disabled tax (isDisabled: true stays true on failure),
      3. Deleting foreignTaxDefault when it is the alphabetically first tax ID (selects a non-deleted enabled tax optimistically and restores original foreignTaxDefault on failure).

What alternative solutions did you explore? (Optional)

  • Only overriding enabled: !value.isDisabled && !isDeleting in WorkspaceTaxesPage.tsx: Rejected because it fixes only the table UI while leaving currentTaxRate.isDisabled stale in Onyx—so TaxOptionsListUtils.ts:78 (getTaxRatesSection) would still leak offline-deleted tax rates into enabledTaxRates in the expense tax picker, WorkspaceEditTaxPage.tsx:120 would still see isDisabled falsy, and TaxRateDeleteMap in TaxRate.ts:283 was already designed to carry isDisabled in the Onyx layer (matching Category.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; at WorkspaceTaxesPage.tsx:170).

cocvn157 avatar Nov 13 '26 15:11 cocvn157

@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.

samithreddychinni avatar Nov 19 '26 13:11 samithreddychinni

@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!