App icon indicating copy to clipboard operation
App copied to clipboard

[$175] [Exploratory] Distance - Can't delete Tax RBR on distance expense after move to another Workspace

Open applause-bot[bot] opened this issue 1 week ago • 8 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.42-1 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://test-management.browserstack.com/projects/2219752/test-runs/84633038/folder/57599980/152206946/1991203578?sort=%2Bidentifier 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: Windows 10/Chrome App Component: Chat Report View

Action Performed:

Preconditions User has two group workspaces, A and B, both with distance rates enabled and only one rate with different default rates Workspace A has a Tax rate set to a Default distance rate Workspace A contains a map distance expense added to a report, and Workspace B contains an empty report

  1. Open the New Dot app
  2. Navigate to Distance expense detail in Workspace A
  3. Click on Report - Select the empty report in Workspace B
  4. Navigate and click on the distance expense in Workspace B
  5. Click on the Tax field

Expected Result:

The Tax field should display a delete modal when clicked and can be deleted (like with Category or Tag RBR when no longer valid)

Actual Result:

Nothing happen

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/d5fbec3c-f0aa-445b-a445-342fd74bf481

View all open jobs on GitHub

Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7318529

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Nov 19 '26 05: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/f256668fc0a76daf1d0511c5e21d0236b1193e0ef084d5c731b290d086008e3d

applause-bot[bot] avatar Nov 19 '26 05:11 applause-bot[bot]

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

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

Proposal

What is the root cause of that problem?

Confidence: Medium — supported by code; web reproduction was blocked.

The Tax field uses the same permission check for editing tax and removing invalid tax. That check excludes all distance expenses. Consequently, an invalid Tax row can display an RBR but has no click handler. The removal confirmation also contains the same restriction, so enabling the click alone would not fix deletion.

Code evidence and symptom chain
  1. Moving the expense can replace its distance rate with the destination workspace’s default while preserving its original tax fields: Transaction.ts:1315–1438.
  2. Retained tax produces taxOutOfPolicy when destination tax tracking is disabled or the carried tax code is unavailable/disabled: ViolationsUtils.ts:1187–1198.
  3. canEditTaxFields = canEdit && !isDistanceRequest blocks distance expenses: MoneyRequestView.tsx:447. The Tax row’s entire click handler depends on it: MoneyRequestView.tsx:1645–1686.
  4. The removal confirmation independently rejects the same case: MoneyRequestView.tsx:912–946.

This explains the no-op even when the user otherwise has permission to edit the expense; a failed API request is not needed to explain it.

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

Separate permission to remove invalid tax from permission to edit valid tax:

  • Allow an editable distance expense to open the removal modal when its retained tax qualifies for removal.
  • Update both the row interaction and confirmation guard; keep valid distance-tax fields non-editable.
  • Reuse the existing removal action, clearing the tax code, value, and amount together.
  • Cover confirmation, cancellation, read-only permissions, valid distance tax, and both Tax rows in regression tests.

Scope to confirm: The existing modal condition covers disabled tax tracking, not every invalid-code RBR. The issue does not specify Workspace B’s tax settings. Verify whether B has disabled distance-tax tracking or enabled tracking with an unavailable code before deciding whether that condition also needs extending.

Removal condition and regression coverage

The current removal condition is at MoneyRequestView.tsx:632–634. Existing clearing behavior is at MoneyRequestView.tsx:923–946. Extend the disabled-tax UI coverage in MoneyRequestViewTest.tsx:568–612.

Automatically recalculating tax during moves is a separate behavior change, not necessary to explain the missing removal interaction.

Web verification — blocked

🤖 Web test steps verification results: ❌ fail

The tester encountered a blank development web page. This is an environment failure, not confirmation that the reported bug reproduces. Blank New Expensify web page blocking verification

Step Status
1. Open app with required preconditionsBlank page; snapshots returned zero nodes after retry.
Blank New Expensify web page blocking verification
❌
2. Open Workspace A expenseBlocked; not executed.
❌
3. Move expense to Workspace B reportBlocked; not executed.
❌
4. Inspect moved expense’s Tax RBRBlocked; not executed.
❌
5. Click Tax and inspect removal modalBlocked; not executed.
❌

Possibly related: Default tax rate of different workspace shown in the other workspace expense also concerns carried tax across workspaces, but is not a confirmed duplicate.


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/107360) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run · no recording available

MelvinBot avatar Nov 23 '26 15:11 MelvinBot

⚠️ Invalid email. Please make sure to create an Expensify account with this email first here.

melvin-bot[bot] avatar Nov 23 '26 17:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 23 '26 17:11 melvin-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

After moving a distance expense that carries a tax rate from Workspace A to an empty report in Workspace B, the moved distance expense displays a Tax no longer valid (taxOutOfPolicy) RBR on the Tax field (alongside the carried-over tax amount), but clicking the Tax field does nothing — no delete confirmation modal opens, so the user cannot remove the invalid tax and clear the RBR.

What is the root cause of that problem?

In src/components/ReportActionItem/MoneyRequestView.tsx, permission to delete an invalid/disabled tax is coupled to canEditTaxFields, which unconditionally excludes distance expenses, and the removal alert condition only covers disabled tax tracking (!isTaxEnabled) rather than all out-of-policy distance tax cases:

  1. canEditTaxFields blocks every distance expense (MoneyRequestView.tsx:447): const canEditTaxFields = canEdit && !isDistanceRequest; is used to gate:
    • The onPress handler on both the Tax row (lines 1656-1675) and Tax amount row (lines 1702-1721), making both rows completely non-interactive on distance expenses.
    • <MenuItem.Chevron /> and <MenuItem.Copy /> on both rows (lines 1684-1685, 1729-1730).
    • The confirmation guard inside showTaxDisabledAlert (line 921: if (action !== ModalActions.CONFIRM || !canEditTaxFields) { return; }), which would still abort deletion even if the modal were opened.
  2. Incomplete removal condition for moved distance expenses (MoneyRequestView.tsx:632-634 vs ViolationsUtils.ts:1192-1193):
    • ViolationsUtils.ts:1192-1193 emits CONST.VIOLATIONS.TAX_OUT_OF_POLICY both when distance tax tracking is disabled on Workspace B (!isPolicyTrackTaxEnabled && hasTransactionTaxData) and when Workspace B has distance tax tracking enabled (isPolicyTrackTaxEnabled) but Workspace A's carried-over taxCode is missing or disabled in Workspace B (!!updatedTransaction.taxCode && !isTaxRateValid).
    • MoneyRequestView.tsx:633 only sets shouldShowTaxDisabledAlert = !isTaxEnabled && !!transaction?.taxCode && !isTimeRequest && !isPerDiemRequest. For a distance expense moved to Workspace B where distance tax tracking is enabled (isTaxEnabled === true) but Workspace A's tax code does not exist in Workspace B, shouldShowTaxDisabledAlert is false even though the expense has a taxOutOfPolicy RBR and cannot open MONEY_REQUEST_STEP_TAX_RATE (since distance tax is derived from the distance rate, not manually editable). Checking only shouldShowTaxDisabledAlert would leave that case unremovable, and checking only !!transaction?.taxCode also misses residual taxValue/taxAmount data that ViolationsUtils.ts:1192 flags.

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

In src/components/ReportActionItem/MoneyRequestView.tsx:

  1. Decouple invalid-tax removal from general tax editing:
    • Compute hasTransactionTaxData = !!transaction?.taxCode || !!transaction?.taxValue || !!transaction?.taxAmount (matching ViolationsUtils.ts:1192) and hasTaxOutOfPolicyViolation = transactionViolations.some((violation) => violation.name === CONST.VIOLATIONS.TAX_OUT_OF_POLICY).
    • Update shouldShowTaxDisabledAlert = !isTaxEnabled && hasTransactionTaxData && !isTimeRequest && !isPerDiemRequest.
    • Define shouldShowTaxRemovalAlert = shouldShowTaxDisabledAlert || (isDistanceRequest && hasTransactionTaxData && hasTaxOutOfPolicyViolation) and canRemoveTax = canEdit && shouldShowTaxRemovalAlert.
    • Define canPressTaxFields = canEditTaxFields || canRemoveTax.
  2. Wire canPressTaxFields / canRemoveTax across both Tax rows and the confirmation callback:
    • In showTaxDisabledAlert (line 921), replace !canEditTaxFields with !canPressTaxFields (or !canEdit || !shouldShowTaxRemovalAlert) so confirming clears taxCode: '', taxValue: '', and taxAmount: 0 via updateMoneyRequestTaxRate — which also clears taxOutOfPolicy via ViolationsUtils.getViolationsOnyxData.
    • On both the Tax row (lines 1656-1686) and Tax amount row (lines 1702-1731):
      • Gate onPress, <MenuItem.Chevron />, and <MenuItem.Copy /> on canPressTaxFields instead of canEditTaxFields.
      • Inside onPress, check if (shouldShowTaxRemovalAlert) { showTaxDisabledAlert(); return; } before navigating to MONEY_REQUEST_STEP_TAX_RATE / MONEY_REQUEST_STEP_TAX_AMOUNT (and keep if (!canEditTaxFields) { return; } as an explicit safeguard so distance expenses never navigate to manual tax-editing screens).
    • Valid distance expenses (where shouldShowTaxRemovalAlert is false) and read-only distance expenses (canEdit === false) retain canPressTaxFields === false, keeping their tax rows non-editable with the Copy icon.
  3. Add unit/UI regression tests in tests/ui/MoneyRequestViewTest.tsx:
    • Distance expense moved to a workspace with distance tax disabled (taxOutOfPolicy + !isTaxEnabled): both Tax and Tax amount show a chevron, pressing either opens the delete confirmation modal, confirming calls updateMoneyRequestTaxRate with empty tax code/value and 0 tax amount, and cancelling leaves tax untouched.
    • Distance expense moved to a workspace with distance tax enabled but an out-of-policy carried-over taxCode (taxOutOfPolicy + isTaxEnabled): pressing Tax opens the delete confirmation modal rather than doing nothing or opening the manual tax picker.
    • Distance expense with a valid tax rate on the destination workspace, and read-only distance expense (canEdit === false): both Tax and Tax amount remain non-clickable with no chevron.

What alternative solutions did you explore? (Optional)

  • Extending only shouldShowTaxDisabledAlert without handling isDistanceRequest && hasTaxOutOfPolicyViolation: Would fix the case where Workspace B has tax tracking disabled, but would still leave a distance expense stuck with an unclickable Tax no longer valid RBR whenever Workspace B has distance tax tracking enabled and Workspace A's taxCode doesn't exist on Workspace B.
  • Allowing distance expenses to navigate to MONEY_REQUEST_STEP_TAX_RATE (canEditTaxFields = canEdit): Incorrect because distance expense tax rates are governed by the workspace's distance rate configuration rather than arbitrary manual selection.
  • Silently wiping or recalculating tax inside changeTransactionsReport (Transaction.ts:1325-1438): Would change cross-workspace move semantics (tracked separately in #103305) rather than matching the expected Category/Tag RBR delete-modal UX requested here, and would not help already-moved expenses that currently carry an invalid tax.

ZeroNeroIV avatar Nov 26 '26 08:11 ZeroNeroIV

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