You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Distance - Tax amount is 0 on created tracked distance expenses even when distance rate has tax configured #87243
Version Number: 9.3.53-0 Reproducible in staging?: Yes Reproducible in production?: Yes Email or phone of affected tester (no customers): Issue reported by: Internal Bug source: Related to #87202
Action Performed:
Precondition:
A workspace with Distance rates and Taxes enabled
Track tax enabled in Distance settings
A distance rate with a non-zero tax rate (e.g. 5%) and a reclaimable amount configured
Go to self DM
Click + > Track distance > Manual
Enter a distance amount and proceed
On the confirm page, select the rate with the 5% tax
Submit the expense
View the created expense
Expected Result:
The created expense should show the correct tax amount based on the configured tax rate on the distance rate.
Actual Result:
The tax amount on the created expense is 0, even though the correct tax rate was selected.
Note: The confirmation page shows the correct tax rate/amount after #87237, but the persisted expense still has a 0 tax amount.
For a tracked distance expense in a self-DM, isPolicyExpenseChat is false and isExpenseUnreported(currentTransaction) is false (draft transaction). So shouldShowTax = false, and the entire tax block at lines 159–170 is skipped when the user selects a rate. The rate's taxRateExternalID is never written to the draft. PR #87237 fixes this part by adding isTrackExpense to the condition.
2. MoneyRequestConfirmationList.tsx:397–413 — initial tax code defaults to policy default, not the distance rate's tax code
Even with PR #87237 applied, there's a second issue: when the confirmation page first renders (before any rate change), the first useEffect sets taxCode to defaultTaxCode (the policy's default tax code from getDefaultTaxCode). This is the policy-level default tax — not the distance rate's specific taxRateExternalID. The second useEffect (line 611–616) then computes tax using this wrong code:
If the policy's default tax rate is 0% (e.g., "Tax exempt") while the selected distance rate has a 5% tax configured via taxRateExternalID, the computed taxAmount = 0. This 0 is persisted to the draft and sent to the TrackExpense API at IOURequestStepConfirmation.tsx:999.
What changes do you think we should make in order to solve the problem?
In MoneyRequestConfirmationList.tsx: When computing the initial/default tax code for distance requests, look up the selected rate's taxRateExternalID from getDistanceRateCustomUnitRate(policy, customUnitRateID)?.attributes?.taxRateExternalID and use it as the effective default instead of defaultTaxCode. This ensures that even on initial render (before any rate change), the tax is computed using the correct rate-specific tax code. The first useEffect (line 397–413) should use this rate-aware default for distance requests, and the tax computation (line 604–605) should similarly prefer the rate's tax code.
What alternative solutions did you explore? (Optional)
An alternative would be to set the rate-specific taxCode on the draft at transaction initialization time (in initMoneyRequest in IOU/index.ts). However, the rate may not be known at that point, and placing the logic in MoneyRequestConfirmationList keeps it consistent with how tax is already computed for the display.
Investigation details
Data flow (bug path):
initMoneyRequest creates draft transaction withouttaxAmount or taxCode (IOU/index.ts:1147)
Confirmation page renders → first useEffect sets taxCode = defaultTaxCode (policy default, not rate-specific)
Second useEffect computes tax using defaultTaxCode → if policy default is 0%, taxAmount = 0
User selects rate with 5% tax → rate page skips tax block (shouldShowTax = false for track expenses)
User returns → confirmation page still has taxCode = defaultTaxCode → tax recomputed as 0
User confirms → IOURequestStepConfirmation.tsx:314 reads transaction?.taxAmount ?? 0 = 0 → sent to API
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
changed the title [-]Distance - Tax amount is 0 on created tracked distance expenses even when distance rate has tax configured[/-][+][$250] Distance - Tax amount is 0 on created tracked distance expenses even when distance rate has tax configured[/+]on Apr 7, 2026
Please re-state the problem that we are trying to solve in this issue.
The tax amount on a created tracked distance expense saves as 0, even when the chosen distance rate has a non-zero tax configured.
What is the root cause of that problem?
Inside MoneyRequestConfirmationList.tsx, the defaultTaxCode is calculated using the policy's default tax code rather than the distance rate's custom tax code:
Because of this, an effect inside MoneyRequestConfirmationList.tsx ends up wrongly initializing the transaction's taxCode and taxAmount onto the draft using the policy's baseline tax (which is 0). The confirmation page background effect overwrites it with the defaultTaxCode behavior, persisting 0 to the backend upon submission.
What changes do you think we should make in order to solve the problem?
In src/components/MoneyRequestConfirmationList.tsx, replace the usage of the bare policy-level defaultTaxCode for distance requests.
Before calculating the default, check if there is a selected customUnitRateID for the distance request, and read taxRateExternalID from it by using: PolicyUtils.getDistanceRateCustomUnitRate(policy, customUnitRateID)?.attributes?.taxRateExternalID
Use this rate-specific tax code as the effective defaultTaxCode. Also, ensure that the taxPercentage calculation uses this rate-specific tax code instead of the generic policy defaultTaxCode. This guarantees that the draft correctly receives the distance rate's tax and properly transmits the correct taxAmount to the backend.
What alternative solutions did you explore? (Optional)
We could push this initialization logic further upstream into initMoneyRequest in IOU/index.ts so that when a distance request draft is created, the rate's taxCode is explicitly placed on the transaction draft right away instead of having MoneyRequestConfirmationList.tsx manage the default computation.
I’d like to submit my proposal to fix the issue where the tax amount on created tracked distance expenses shows as 0 even when the distance rate has a tax configured.
Root Cause Analysis:
The problem occurs due to two main reasons:
IOURequestStepDistanceRate.tsx – The shouldShowTax condition excludes tracked distance expenses. As a result, when creating a tracked distance expense, the selected rate’s taxRateExternalID is never saved to the draft. PR #87237 partially addresses this, but not completely.
MoneyRequestConfirmationList.tsx – On initial render, the tax code defaults to the policy’s default tax code rather than the selected distance rate’s tax. If the policy default tax is 0%, the persisted expense shows 0 tax, even if the selected rate has a non-zero tax configured.
Proposed Solution:
Update IOURequestStepDistanceRate.tsx:
Include isTrackExpense in the shouldShowTax condition to ensure the tax block executes for tracked distance expenses:
shouldShowTax = isTaxTrackingEnabled(
isPolicyExpenseChat || isExpenseUnreported(currentTransaction) || isTrackExpense,
...
);
Update MoneyRequestConfirmationList.tsx:
Use the selected rate’s taxRateExternalID as the effective default tax code during initial render:
const rateTaxCode = getDistanceRateCustomUnitRate(policy, customUnitRateID)?.attributes?.taxRateExternalID;
This ensures that even on first render, the correct tax is computed and persisted.
Alternative Solutions Explored:
Setting the rate-specific tax at transaction initialization. This is less optimal because the selected rate may not be known yet, and it could break the existing display logic.
Thank you for considering my proposal. I am confident this solution will resolve the tax calculation issue for all tracked distance expenses and ensure correct persistence across the app.
Please re-state the problem that we are trying to solve in this issue.
When submitting a manual distance expense with a distance rate that has tax enabled (for example 5%), the confirmation screen correctly shows tax, but the created expense is persisted with taxAmount = 0.
What is the root cause of that problem?
The tax shown on confirmation is computed in UI state, but the persisted TrackExpense payload can still read stale transaction draft values.
In MoneyRequestConfirmationList, tax is calculated and then written to the draft in a useEffect:
// First we'll try to get the tax value from the chosen policy and if not found, we'll try to get it from the policy for moving expenses (only if the transaction is moving from track expense)
So if submit happens before draft tax sync is committed, payload tax remains 0 even though confirmation UI displays the computed tax.
What changes do you think we should make in order to solve the problem?
Guarantee tax is finalized before submit for distance flows: Recompute tax at submit time in IOURequestStepConfirmation (using the same formula as confirmation UI), and pass that computed value to trackExpenseIOUActions. Use this computed value as source of truth when isDistanceRequest is true.
Keep draft tax synchronized earlier: Continue draft updates in confirmation, but avoid relying on async useEffect timing as the only source before API call. Use per-item tax in submit loop:
In transactions.entries() submit path, prefer item.taxCode/taxAmount/taxValue (with fallback) so each submitted transaction carries correct tax.
Optional hardening in TrackExpense: Avoid treating 0 as “missing” in optimistic transaction construction (taxAmount ? ... : undefined), and instead handle explicit zero/non-zero values more safely.
This ensures persisted tax always matches the selected distance rate and confirmation calculation.
What alternative solutions did you explore? (Optional)
Please re-state the problem that we are trying to solve in this issue.
When a user creates a tracked distance expense with a tax-configured distance rate, the tax amount is saved as 0 even though the confirmation screen displays the correct tax.
What is the root cause of that problem?
TaxController's first useEffect in TaxController writes taxAmount: transactionTaxAmount ?? null to the draft. On initial render, transactionTaxAmount is undefined, so null is written. The second useEffect subsequently writes the correct calculated taxAmountInSmallestCurrencyUnits, but both are async Onyx.merge calls. When IOURequestStepConfirmation reads transaction?.taxAmount ?? 0, it can get the stale null (→ 0). This 0 is then passed to trackExpense, and in TrackExpense the expression taxAmount ? -taxAmount : undefined treats 0 as falsy, cementing it as undefined/0 in the optimistic transaction.
What changes do you think we should make in order to solve the problem?
In TaxController, change the first useEffect's taxAmount fallback so it never writes null when a calculated value is available:
// Before (line 46):taxAmount: transactionTaxAmount??null,// After:taxAmount: transactionTaxAmount??taxAmountInSmallestCurrencyUnits??null,
This ensures the first effect always uses the calculated tax as fallback, eliminating the window where null can be written to the draft before the second effect fires.
What alternative solutions did you explore? (Optional)
MelvinBot's and KJ21-ENG's proposals fix defaultTaxCode resolution in MoneyRequestConfirmationList — but the actual disconnect is in TaxController writing null to the draft before the correct value is computed, not in which tax code is used. Abdullahtmk's proposal recomputes tax at submit time in IOURequestStepConfirmation, which works but duplicates calculation logic across two files. This one-line fix in TaxController addresses the race at its source without duplicating any logic.
I investigated this one, and it looks like this is indeed a regression from #84136, and it is not a backend issue, because the backend only stores the tax amount when it is manually modified. Otherwise, it doesn't return it, and it has to be computed from the tax value (percentage). cc @FitseTLT@parasharrajat
📣 @FitseTLT 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!
Offer link Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Keep in mind: Code of Conduct | Contributing 📖
Activity
MelvinBot commentedon Apr 7, 2026
Proposal
What is the root cause of that problem?
There are two compounding issues causing the tax amount to persist as 0:
1.
IOURequestStepDistanceRate.tsx:84—shouldShowTaxexcludes track expensesFor a tracked distance expense in a self-DM,
isPolicyExpenseChatisfalseandisExpenseUnreported(currentTransaction)isfalse(draft transaction). SoshouldShowTax=false, and the entire tax block at lines 159–170 is skipped when the user selects a rate. The rate'staxRateExternalIDis never written to the draft. PR #87237 fixes this part by addingisTrackExpenseto the condition.2.
MoneyRequestConfirmationList.tsx:397–413— initial tax code defaults to policy default, not the distance rate's tax codeEven with PR #87237 applied, there's a second issue: when the confirmation page first renders (before any rate change), the first
useEffectsetstaxCodetodefaultTaxCode(the policy's default tax code fromgetDefaultTaxCode). This is the policy-level default tax — not the distance rate's specifictaxRateExternalID. The seconduseEffect(line 611–616) then computes tax using this wrong code:If the policy's default tax rate is 0% (e.g., "Tax exempt") while the selected distance rate has a 5% tax configured via
taxRateExternalID, the computedtaxAmount= 0. This 0 is persisted to the draft and sent to theTrackExpenseAPI atIOURequestStepConfirmation.tsx:999.What changes do you think we should make in order to solve the problem?
Two changes are needed:
In
IOURequestStepDistanceRate.tsx(PR [CP Staging] Fix tax in confirmation page when creating a tracked distance request #87237's fix): AddisTrackExpenseto theshouldShowTaxcondition so that selecting a distance rate for tracked expenses correctly saves the rate'staxRateExternalID,taxAmount, andtaxValueto the draft.In
MoneyRequestConfirmationList.tsx: When computing the initial/default tax code for distance requests, look up the selected rate'staxRateExternalIDfromgetDistanceRateCustomUnitRate(policy, customUnitRateID)?.attributes?.taxRateExternalIDand use it as the effective default instead ofdefaultTaxCode. This ensures that even on initial render (before any rate change), the tax is computed using the correct rate-specific tax code. The firstuseEffect(line 397–413) should use this rate-aware default for distance requests, and the tax computation (line 604–605) should similarly prefer the rate's tax code.What alternative solutions did you explore? (Optional)
An alternative would be to set the rate-specific
taxCodeon the draft at transaction initialization time (ininitMoneyRequestinIOU/index.ts). However, the rate may not be known at that point, and placing the logic inMoneyRequestConfirmationListkeeps it consistent with how tax is already computed for the display.Investigation details
Data flow (bug path):
initMoneyRequestcreates draft transaction withouttaxAmountortaxCode(IOU/index.ts:1147)useEffectsetstaxCode = defaultTaxCode(policy default, not rate-specific)useEffectcomputes tax usingdefaultTaxCode→ if policy default is 0%,taxAmount = 0shouldShowTax = falsefor track expenses)taxCode = defaultTaxCode→ tax recomputed as 0IOURequestStepConfirmation.tsx:314readstransaction?.taxAmount ?? 0= 0 → sent to APIKey files:
src/pages/iou/request/step/IOURequestStepDistanceRate.tsx:84,159–170— rate page tax logicsrc/components/MoneyRequestConfirmationList.tsx:389,397–413,601–616— confirmation page tax computationsrc/pages/iou/request/step/IOURequestStepConfirmation.tsx:314,999— reads taxAmount and sends to APIsrc/libs/PolicyUtils.ts:236–239—getDistanceRateCustomUnitRate(used to get rate'staxRateExternalID)src/libs/PolicyUtils.ts:835–851—isTaxTrackingEnabledRelated issues:
Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.melvin-bot commentedon Apr 7, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @dukenv0307 (
External)[-]Distance - Tax amount is 0 on created tracked distance expenses even when distance rate has tax configured[/-][+][$250] Distance - Tax amount is 0 on created tracked distance expenses even when distance rate has tax configured[/+]melvin-bot commentedon Apr 7, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022041486589785177521
KJ21-ENG commentedon Apr 7, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
The tax amount on a created tracked distance expense saves as
0, even when the chosen distance rate has a non-zero tax configured.What is the root cause of that problem?
Inside
MoneyRequestConfirmationList.tsx, thedefaultTaxCodeis calculated using the policy's default tax code rather than the distance rate's custom tax code:App/src/components/MoneyRequestConfirmationList.tsx
Lines 391 to 393 in a0abb60
This policy default code is what drives the computed
taxPercentageand the resultingtaxAmount:App/src/components/MoneyRequestConfirmationList.tsx
Lines 604 to 608 in a0abb60
Because of this, an effect inside
MoneyRequestConfirmationList.tsxends up wrongly initializing the transaction'staxCodeandtaxAmountonto the draft using the policy's baseline tax (which is0). The confirmation page background effect overwrites it with thedefaultTaxCodebehavior, persisting0to the backend upon submission.What changes do you think we should make in order to solve the problem?
In
src/components/MoneyRequestConfirmationList.tsx, replace the usage of the bare policy-leveldefaultTaxCodefor distance requests.Before calculating the default, check if there is a selected
customUnitRateIDfor the distance request, and readtaxRateExternalIDfrom it by using:PolicyUtils.getDistanceRateCustomUnitRate(policy, customUnitRateID)?.attributes?.taxRateExternalIDUse this rate-specific tax code as the effective
defaultTaxCode. Also, ensure that thetaxPercentagecalculation uses this rate-specific tax code instead of the generic policydefaultTaxCode. This guarantees that the draft correctly receives the distance rate's tax and properly transmits the correcttaxAmountto the backend.What alternative solutions did you explore? (Optional)
We could push this initialization logic further upstream into
initMoneyRequestinIOU/index.tsso that when a distance request draft is created, the rate'staxCodeis explicitly placed on the transaction draft right away instead of havingMoneyRequestConfirmationList.tsxmanage the default computation.JasimMalook commentedon Apr 7, 2026
Hello Expensify Team,
I’d like to submit my proposal to fix the issue where the tax amount on created tracked distance expenses shows as 0 even when the distance rate has a tax configured.
Root Cause Analysis:
The problem occurs due to two main reasons:
IOURequestStepDistanceRate.tsx – The shouldShowTax condition excludes tracked distance expenses. As a result, when creating a tracked distance expense, the selected rate’s taxRateExternalID is never saved to the draft. PR #87237 partially addresses this, but not completely.
MoneyRequestConfirmationList.tsx – On initial render, the tax code defaults to the policy’s default tax code rather than the selected distance rate’s tax. If the policy default tax is 0%, the persisted expense shows 0 tax, even if the selected rate has a non-zero tax configured.
Proposed Solution:
Update IOURequestStepDistanceRate.tsx:
Include isTrackExpense in the shouldShowTax condition to ensure the tax block executes for tracked distance expenses:
shouldShowTax = isTaxTrackingEnabled(
isPolicyExpenseChat || isExpenseUnreported(currentTransaction) || isTrackExpense,
...
);
Update MoneyRequestConfirmationList.tsx:
Use the selected rate’s taxRateExternalID as the effective default tax code during initial render:
const rateTaxCode = getDistanceRateCustomUnitRate(policy, customUnitRateID)?.attributes?.taxRateExternalID;
This ensures that even on first render, the correct tax is computed and persisted.
Alternative Solutions Explored:
Setting the rate-specific tax at transaction initialization. This is less optimal because the selected rate may not be known yet, and it could break the existing display logic.
Contributor Details:
Name: Jasim Malook
Email: jasimmalook@gmail.com
Upwork Profile: https://www.upwork.com/freelancers/~014c25762fc2275193
Thank you for considering my proposal. I am confident this solution will resolve the tax calculation issue for all tracked distance expenses and ensure correct persistence across the app.
Abdullahtmk commentedon Apr 7, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When submitting a manual distance expense with a distance rate that has tax enabled (for example 5%), the confirmation screen correctly shows tax, but the created expense is persisted with taxAmount = 0.
What is the root cause of that problem?
The tax shown on confirmation is computed in UI state, but the persisted TrackExpense payload can still read stale transaction draft values.
In MoneyRequestConfirmationList, tax is calculated and then written to the draft in a useEffect:
App/src/components/MoneyRequestConfirmationList.tsx
Lines 601 to 606 in 4362d1c
But IOURequestStepConfirmation builds submit params from
App/src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Line 314 in 4362d1c
And this transaction amount is passed to trackExpenseIOUActions as
App/src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Line 999 in 4362d1c
So if submit happens before draft tax sync is committed, payload tax remains 0 even though confirmation UI displays the computed tax.
What changes do you think we should make in order to solve the problem?
Guarantee tax is finalized before submit for distance flows: Recompute tax at submit time in IOURequestStepConfirmation (using the same formula as confirmation UI), and pass that computed value to trackExpenseIOUActions. Use this computed value as source of truth when isDistanceRequest is true.
Keep draft tax synchronized earlier: Continue draft updates in confirmation, but avoid relying on async useEffect timing as the only source before API call. Use per-item tax in submit loop:
In transactions.entries() submit path, prefer item.taxCode/taxAmount/taxValue (with fallback) so each submitted transaction carries correct tax.
Optional hardening in TrackExpense: Avoid treating 0 as “missing” in optimistic transaction construction (taxAmount ? ... : undefined), and instead handle explicit zero/non-zero values more safely.
This ensures persisted tax always matches the selected distance rate and confirmation calculation.
What alternative solutions did you explore? (Optional)
N/A
twilight2294 commentedon Apr 8, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user creates a tracked distance expense with a tax-configured distance rate, the tax amount is saved as 0 even though the confirmation screen displays the correct tax.
What is the root cause of that problem?
TaxController's firstuseEffectin TaxController writestaxAmount: transactionTaxAmount ?? nullto the draft. On initial render,transactionTaxAmountisundefined, sonullis written. The seconduseEffectsubsequently writes the correct calculatedtaxAmountInSmallestCurrencyUnits, but both are asyncOnyx.mergecalls. When IOURequestStepConfirmation readstransaction?.taxAmount ?? 0, it can get the stalenull(→0). This0is then passed totrackExpense, and in TrackExpense the expressiontaxAmount ? -taxAmount : undefinedtreats0as falsy, cementing it asundefined/0in the optimistic transaction.What changes do you think we should make in order to solve the problem?
In TaxController, change the first
useEffect'staxAmountfallback so it never writesnullwhen a calculated value is available:This ensures the first effect always uses the calculated tax as fallback, eliminating the window where
nullcan be written to the draft before the second effect fires.What alternative solutions did you explore? (Optional)
MelvinBot's and KJ21-ENG's proposals fix
defaultTaxCoderesolution inMoneyRequestConfirmationList— but the actual disconnect is inTaxControllerwritingnullto the draft before the correct value is computed, not in which tax code is used. Abdullahtmk's proposal recomputes tax at submit time inIOURequestStepConfirmation, which works but duplicates calculation logic across two files. This one-line fix inTaxControlleraddresses the race at its source without duplicating any logic.10 remaining items
cristipaval commentedon Apr 16, 2026
I investigated this one, and it looks like this is indeed a regression from #84136, and it is not a backend issue, because the backend only stores the tax amount when it is manually modified. Otherwise, it doesn't return it, and it has to be computed from the tax value (percentage). cc @FitseTLT @parasharrajat
melvin-bot commentedon Apr 16, 2026
📣 @FitseTLT 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!
Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Keep in mind: Code of Conduct | Contributing 📖
cristipaval commentedon Apr 16, 2026
I've just assigned the authors of the offending PR to fix it.
FitseTLT commentedon Apr 17, 2026
This is not reproducible for me @cristipaval
2026-04-17.17-32-38.mp4
cristipaval commentedon Apr 17, 2026
Requested a retest here
IuliiaHerets commentedon Apr 17, 2026
@cristipaval Issue is not repro on Chrome / v9.3.60-14
Screen.Recording.2026-04-17.at.18.25.02.mp4
cristipaval commentedon Apr 17, 2026
lovely. CLosing