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
[Due for payment 2026-05-22] [$250] [Unreported] Distance - After editing distance, Distance rate changes to personal rate #87204
Version Number: 9.3.53-0 Reproducible in staging?: Yes Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught during regression testing, add the test name, ID and link from BrowserStack:#84136 Email or phone of affected tester (no customers):sjoinjojsodidsjodjso@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.2 / Chrome App Component: Money Requests
Action Performed:
Go to staging.new.expensify.com
Go to self DM.
Create a manual distance expense.
Open the expense.
Click Distance.
Edit distance and save it.
Expected Result:
After editing distance, Distance rate will not change to personal default rate.
Actual Result:
After editing distance, Distance rate changes to personal default rate.
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
Classification: Frontend bug
Causing PR: #84136 "Feat - Add distance rate to the distance expenses tracked in selfDM" by @FitseTLT (High confidence)
Recommendation: REVERT
PR #84136 introduced the bug. When track tax is enabled and the user edits the distance on a track expense, the distance rate resets to the personal default rate instead of preserving the previously-selected rate.
Labels: DeployBlockerCash is kept (App PR caused this). DeployBlocker is being removed as this is a frontend bug requiring a fix in Expensify/App, not the backend.
Verification - Key files modified by PR #84136 related to the bug:
src/libs/DistanceRequestUtils.ts - The getCustomUnitRateID function was changed so that when isTrackDistanceExpense is true, it skips the lastSelectedDistanceRates lookup entirely and always returns the policy default rate. When the user edits the distance amount, this overrides the previously-selected rate (e.g., the one with 5% tax) with the policy default.
src/pages/iou/request/step/IOURequestStepDistanceManual.tsx - The PR removed customUnitRateID from the args passed to handleMoneyRequestStepDistanceNavigation, so the user-selected rate is no longer forwarded when navigating after editing the manual distance.
Root Cause:
In DistanceRequestUtils.getCustomUnitRateID, for isTrackDistanceExpense: true, the condition that preserves lastSelectedDistanceRate was gated out (!isTrackDistanceExpense &&). When the user edits the distance amount on a track expense that has a custom rate with 5% tax selected, handleMoneyRequestStepDistanceNavigation calls getCustomUnitRateID with isTrackDistanceExpense: true, bypassing the previously-selected rate and returning the policy default rate. This rate reset then also discards the tax association, causing the behavior seen in the video.
Please re-state the problem that we are trying to solve in this issue.
When track tax is enabled and a user edits the distance on a self-DM track expense that uses a workspace distance rate, the rate resets to the personal default rate.
What is the root cause of that problem?
The usePolicyForTransaction hook at src/hooks/usePolicyForTransaction.ts:48-51 only returns policyForMovingExpenses (the workspace policy that owns the selected rate) when action === CREATE && iouType === TRACK. During an edit (action === EDIT), it falls through to reportPolicy — which is the self-DM's personal policy since the transaction thread inherits policyID from the self-DM parent report.
This wrong policy is then passed through updateMoneyRequestDistance → getUpdatedTransaction → DistanceRequestUtils.getRate(). Since the workspace rate's customUnitRateID doesn't exist in the personal policy's mileage rates, getRate() falls back to the personal policy's defaultMileageRate at src/libs/DistanceRequestUtils.ts:431-432. The recalculated amount, currency, and merchant are then written optimistically with the wrong rate.
What changes do you think we should make in order to fix the problem?
Update the condition in usePolicyForTransaction (line 51) to also use policyForMovingExpenses when editing a self-DM track expense — not just when creating one. The fix:
// Current (broken for edits):constisCreatingTrackExpense=action===CONST.IOU.ACTION.CREATE&&iouType===CONST.IOU.TYPE.TRACK;// Fixed:constisSelfDMTrackExpense=iouType===CONST.IOU.TYPE.TRACK;constisCreatingTrackExpense=action===CONST.IOU.ACTION.CREATE&&isSelfDMTrackExpense;
This ensures policyForMovingExpenses is used during both creation and editing of self-DM track expenses, so getRate() can find the correct customUnitRateID in the workspace policy.
Investigation details
Data flow of the bug:
User creates distance expense in self-DM, selecting a rate from workspace policy (e.g., 5% tax)
Transaction is created with customUnitRateID from workspace policy
User edits distance → IOURequestStepDistanceManual resolves policy via usePolicyForTransaction({reportPolicyID: report?.policyID, action, iouType, transaction}) at line 79
Since action=EDIT, isCreatingTrackExpense is false → policy resolves to reportPolicy (self-DM policy)
Wrong policy passed to updateMoneyRequestDistance at line 195-210
getUpdatedTransaction calls DistanceRequestUtils.getRate({transaction, policy}) at line 866 with wrong policy
Rate lookup fails → falls back to personal default rate
Wrong amount/currency/merchant written optimistically
Why it only manifests with track tax enabled: Tax-enabled expenses use workspace rates that differ from the personal default. Without tax, the personal default rate may coincidentally match, masking the bug.
What alternative solutions did you explore? (Optional)
An alternative would be to look up the correct policy directly from the transaction's customUnitRateID inside getUpdatedTransaction in TransactionUtils/index.ts. However, this would require passing all policies to a utility function. Fixing the hook at the source (usePolicyForTransaction) is cleaner since it already has access to policyForMovingExpenses.
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.
Activity
melvin-bot commentedon Apr 7, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #84136
melvin-bot commentedon Apr 7, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Apr 7, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
OSBotify commentedon Apr 7, 2026
Investigation Summary
Classification: Frontend bug
Causing PR: #84136 "Feat - Add distance rate to the distance expenses tracked in selfDM" by @FitseTLT (High confidence)
Recommendation: REVERT
PR #84136 introduced the bug. When track tax is enabled and the user edits the distance on a track expense, the distance rate resets to the personal default rate instead of preserving the previously-selected rate.
Labels: DeployBlockerCash is kept (App PR caused this). DeployBlocker is being removed as this is a frontend bug requiring a fix in Expensify/App, not the backend.
Evidence:
Verification - Key files modified by PR #84136 related to the bug:
src/libs/DistanceRequestUtils.ts - The getCustomUnitRateID function was changed so that when isTrackDistanceExpense is true, it skips the lastSelectedDistanceRates lookup entirely and always returns the policy default rate. When the user edits the distance amount, this overrides the previously-selected rate (e.g., the one with 5% tax) with the policy default.
src/pages/iou/request/step/IOURequestStepDistanceManual.tsx - The PR removed customUnitRateID from the args passed to handleMoneyRequestStepDistanceNavigation, so the user-selected rate is no longer forwarded when navigating after editing the manual distance.
Root Cause:
In DistanceRequestUtils.getCustomUnitRateID, for isTrackDistanceExpense: true, the condition that preserves lastSelectedDistanceRate was gated out (!isTrackDistanceExpense &&). When the user edits the distance amount on a track expense that has a custom rate with 5% tax selected, handleMoneyRequestStepDistanceNavigation calls getCustomUnitRateID with isTrackDistanceExpense: true, bypassing the previously-selected rate and returning the policy default rate. This rate reset then also discards the tax association, causing the behavior seen in the video.
MelvinBot commentedon Apr 7, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When track tax is enabled and a user edits the distance on a self-DM track expense that uses a workspace distance rate, the rate resets to the personal default rate.
What is the root cause of that problem?
The
usePolicyForTransactionhook atsrc/hooks/usePolicyForTransaction.ts:48-51only returnspolicyForMovingExpenses(the workspace policy that owns the selected rate) whenaction === CREATE && iouType === TRACK. During an edit (action === EDIT), it falls through toreportPolicy— which is the self-DM's personal policy since the transaction thread inheritspolicyIDfrom the self-DM parent report.This wrong policy is then passed through
updateMoneyRequestDistance→getUpdatedTransaction→DistanceRequestUtils.getRate(). Since the workspace rate'scustomUnitRateIDdoesn't exist in the personal policy's mileage rates,getRate()falls back to the personal policy'sdefaultMileageRateatsrc/libs/DistanceRequestUtils.ts:431-432. The recalculated amount, currency, and merchant are then written optimistically with the wrong rate.What changes do you think we should make in order to fix the problem?
Update the condition in
usePolicyForTransaction(line 51) to also usepolicyForMovingExpenseswhen editing a self-DM track expense — not just when creating one. The fix:Then update line 51:
This ensures
policyForMovingExpensesis used during both creation and editing of self-DM track expenses, sogetRate()can find the correctcustomUnitRateIDin the workspace policy.Investigation details
Data flow of the bug:
customUnitRateIDfrom workspace policyIOURequestStepDistanceManualresolvespolicyviausePolicyForTransaction({reportPolicyID: report?.policyID, action, iouType, transaction})at line 79action=EDIT,isCreatingTrackExpenseis false → policy resolves toreportPolicy(self-DM policy)updateMoneyRequestDistanceat line 195-210getUpdatedTransactioncallsDistanceRequestUtils.getRate({transaction, policy})at line 866 with wrong policyWhy it only manifests with track tax enabled: Tax-enabled expenses use workspace rates that differ from the personal default. Without tax, the personal default rate may coincidentally match, masking the bug.
What alternative solutions did you explore? (Optional)
An alternative would be to look up the correct policy directly from the transaction's
customUnitRateIDinsidegetUpdatedTransactioninTransactionUtils/index.ts. However, this would require passing all policies to a utility function. Fixing the hook at the source (usePolicyForTransaction) is cleaner since it already has access topolicyForMovingExpenses.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.47 remaining items
melvin-bot commentedon May 21, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)mallenexpensify commentedon May 22, 2026
Payment Summary
Contributor+: @FitseTLT paid $250 via Upwork.
^ Test case created. Thx
FitseTLT commentedon May 22, 2026
nope @mallenexpensify
It would also be nice if melvin knew the ND payed contributors list and auto generates the note to help you 🤔
FitseTLT commentedon Jun 2, 2026
@mallenexpensify on the above
mallenexpensify commentedon Jun 2, 2026
@FitseTLT paid, summary updated above. Thx.
We're actively working on an improvement that will help (then we'll likely need another too, based on how frequently I mess it up.)