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-03-13] [$250] Distance - Distance unit and rate change after editing distance #83953
Version Number: 9.3.28-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:#74967 Email or phone of affected tester (no customers):isodjnosidjiojiojiso@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:
Precondition:
Workspace distance unit must be different from personal distance unit.
Go to staging.new.expensify.com
Go to self DM.
Create a manual distance expense.
Open the expense.
Click Distance.
Edit the distance and save it.
Expected Result:
Distance unit and rate will not change after editing distance.
Actual Result:
Distance unit and rate change to personal distance unit and rate after editing distance.
👋 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: #74967 - "Fix - [Unreported] Add distance rate to the distance expenses tracked in selfDM" by @FitseTLT (High confidence) Related Issues: None
Recommendation: ROLL FORWARD
PR #74967 added the feature to allow workspace distance rates for track expenses in self DM, but missed updating the edit distance flow to use the correct policy reference. The fix is straightforward - a one-line change to pass the correct policy parameter.
Labels: No label changes made. Keeping DeployBlockerCash as this is a frontend bug that requires an App PR fix.
📋 Detailed Analysis
Evidence
PR #74967 was merged on 2026-02-28 and added support for workspace distance rates on track expenses in self DM. The issue reproduction steps match this new feature:
Create a distance expense in self DM with workspace distance unit different from personal unit
Edit the distance
Distance unit and rate incorrectly change to personal unit/rate
Verification
The bug occurs in /home/runner/_work/App/App/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx:
Line 76: Gets the policy from the report
constpolicy=usePolicy(report?.policyID);
Line 82: Gets the policy for moving expenses (for track expenses)
Line 191: PROBLEM - Uses wrong policy for track expenses
policy,// Should use policyForMovingExpenses for track expenses
For track expenses in self DM, report?.policyID is undefined or refers to the personal policy, not the workspace policy. PR #74967 added policyForMovingExpenses to handle this, but the edit flow at line 191 still uses policy instead.
Root Cause
When updateMoneyRequestDistance is called during edit:
It passes policy (personal policy for self DM reports)
This flows down to getUpdatedTransaction in /home/runner/_work/App/App/src/libs/TransactionUtils/index.ts
At line 726, it calls DistanceRequestUtils.getRate({transaction: updatedTransaction, policy})
Since the policy is personal policy, it returns the personal P2P rate instead of the workspace rate
The transaction gets updated with wrong unit/rate
The fix is to check if this is a track expense (iouType === CONST.IOU.TYPE.TRACK) and use policyForMovingExpenses instead of policy when calling updateMoneyRequestDistance.
Proposed Fix
In /home/runner/_work/App/App/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx at line 191:
Please re-state the problem that we are trying to solve in this issue.
When editing a distance expense tracked in selfDM, the distance unit and rate change to personal defaults (e.g., miles) instead of keeping the original workspace's unit and rate (e.g., km). This happens when the workspace distance unit differs from the personal distance unit.
What is the root cause of that problem?
The distance editing step pages (IOURequestStepDistanceManual.tsx and IOURequestStepDistance.tsx) resolve the policy via usePolicy(report?.policyID) (lines 76 and 91 respectively). For selfDM transaction thread reports, report?.policyID is undefined, so policy resolves to null.
This null policy is then passed to DistanceRequestUtils.getRate() with useTransactionDistanceUnit: false (line 111-115 of IOURequestStepDistanceManual.tsx). Inside getRate():
getMileageRates(null) returns {} (empty)
getDefaultMileageRate(null) returns undefined
getDistanceUnit(undefined, undefined) falls back to CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES
So the unit defaults to miles and rate to undefined. When the user saves, setMoneyRequestDistance() overwrites the transaction's distanceUnit with 'mi', and updateMoneyRequestDistance() recalculates the amount using the wrong unit/rate.
By contrast, IOURequestStepDistanceRate.tsx (the rate editing page) uses usePolicyForTransaction() at line 66, which correctly resolves to policyForMovingExpenses for selfDM expenses. This inconsistency was introduced by PR #74967, which updated the rate page to use usePolicyForTransaction but did not update the distance editing pages.
What changes do you think we should make in order to solve the problem?
In IOURequestStepDistanceManual.tsx and IOURequestStepDistance.tsx: Replace usePolicy(report?.policyID) with usePolicyForTransaction({transaction, reportPolicyID: report?.policyID, action, iouType, policyDraft}), matching what IOURequestStepDistanceRate.tsx already does. This ensures the correct workspace policy is resolved for selfDM track expenses.
In usePolicyForTransaction.ts: The current logic at line 51 only returns policyForSelfDMExpense for unreported expenses (transaction.reportID === UNREPORTED_REPORT_ID) or creating track expenses (action === CREATE && iouType === TRACK). SelfDM expenses being edited may not meet either condition. The condition should also cover editing track expenses in selfDM (when action === EDIT and the expense is in selfDM).
What alternative solutions did you explore? (Optional)
An alternative would be to pass policyForMovingExpenses through the getUpdatedTransaction() call chain in TransactionUtils/index.ts (lines 726, 777, 863 all call getRate() without policyForMovingExpenses). However, fixing the policy resolution at the component level is a cleaner approach since it addresses the root cause — the wrong policy being passed into the entire save flow — rather than patching individual call sites.
Confidence: High — the evidence chain is complete from policy resolution → rate lookup → unit fallback → wrong save data. The rate editing page (IOURequestStepDistanceRate.tsx) already demonstrates the correct pattern at line 66.
Relevant Code:
src/pages/iou/request/step/IOURequestStepDistanceManual.tsx:76 — uses usePolicy(report?.policyID) (wrong for selfDM)
src/pages/iou/request/step/IOURequestStepDistance.tsx:91 — same issue
changed the title [-][$250] Distance - Distance unit and rate change after editing distance[/-][+][Due for payment 2026-03-13] [$250] Distance - Distance unit and rate change after editing distance[/+]on Mar 6, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.31-12 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@parasharrajat / @FitseTLT@heyjennahay The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
Activity
melvin-bot commentedon Mar 2, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #74967
melvin-bot commentedon Mar 2, 2026
💬 A slack conversation has been started in #expensify-open-source
melvin-bot commentedon Mar 2, 2026
Triggered auto assignment to @heyjennahay (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.github-actions commentedon Mar 2, 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 Mar 2, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #74967 - "Fix - [Unreported] Add distance rate to the distance expenses tracked in selfDM" by @FitseTLT (High confidence)
Related Issues: None
Recommendation: ROLL FORWARD
PR #74967 added the feature to allow workspace distance rates for track expenses in self DM, but missed updating the edit distance flow to use the correct policy reference. The fix is straightforward - a one-line change to pass the correct policy parameter.
Labels: No label changes made. Keeping
DeployBlockerCashas this is a frontend bug that requires an App PR fix.📋 Detailed Analysis
Evidence
PR #74967 was merged on 2026-02-28 and added support for workspace distance rates on track expenses in self DM. The issue reproduction steps match this new feature:
Verification
The bug occurs in
/home/runner/_work/App/App/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx:Line 76: Gets the policy from the report
Line 82: Gets the policy for moving expenses (for track expenses)
Line 191: PROBLEM - Uses wrong policy for track expenses
For track expenses in self DM,
report?.policyIDis undefined or refers to the personal policy, not the workspace policy. PR #74967 addedpolicyForMovingExpensesto handle this, but the edit flow at line 191 still usespolicyinstead.Root Cause
When
updateMoneyRequestDistanceis called during edit:policy(personal policy for self DM reports)getUpdatedTransactionin/home/runner/_work/App/App/src/libs/TransactionUtils/index.tsDistanceRequestUtils.getRate({transaction: updatedTransaction, policy})The fix is to check if this is a track expense (
iouType === CONST.IOU.TYPE.TRACK) and usepolicyForMovingExpensesinstead ofpolicywhen callingupdateMoneyRequestDistance.Proposed Fix
In
/home/runner/_work/App/App/src/pages/iou/request/step/IOURequestStepDistanceManual.tsxat line 191:This same fix likely needs to be applied to other distance edit pages:
IOURequestStepDistanceMap.tsxIOURequestStepDistanceOdometer.tsxIOURequestStepDistance.tsx(if it has similar edit logic)MelvinBot commentedon Mar 2, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When editing a distance expense tracked in selfDM, the distance unit and rate change to personal defaults (e.g., miles) instead of keeping the original workspace's unit and rate (e.g., km). This happens when the workspace distance unit differs from the personal distance unit.
What is the root cause of that problem?
The distance editing step pages (
IOURequestStepDistanceManual.tsxandIOURequestStepDistance.tsx) resolve the policy viausePolicy(report?.policyID)(lines 76 and 91 respectively). For selfDM transaction thread reports,report?.policyIDisundefined, sopolicyresolves tonull.This null policy is then passed to
DistanceRequestUtils.getRate()withuseTransactionDistanceUnit: false(line 111-115 ofIOURequestStepDistanceManual.tsx). InsidegetRate():getMileageRates(null)returns{}(empty)getDefaultMileageRate(null)returnsundefinedgetDistanceUnit(undefined, undefined)falls back toCONST.CUSTOM_UNITS.DISTANCE_UNIT_MILESSo the unit defaults to miles and rate to undefined. When the user saves,
setMoneyRequestDistance()overwrites the transaction'sdistanceUnitwith'mi', andupdateMoneyRequestDistance()recalculates the amount using the wrong unit/rate.By contrast,
IOURequestStepDistanceRate.tsx(the rate editing page) usesusePolicyForTransaction()at line 66, which correctly resolves topolicyForMovingExpensesfor selfDM expenses. This inconsistency was introduced by PR #74967, which updated the rate page to useusePolicyForTransactionbut did not update the distance editing pages.What changes do you think we should make in order to solve the problem?
In
IOURequestStepDistanceManual.tsxandIOURequestStepDistance.tsx: ReplaceusePolicy(report?.policyID)withusePolicyForTransaction({transaction, reportPolicyID: report?.policyID, action, iouType, policyDraft}), matching whatIOURequestStepDistanceRate.tsxalready does. This ensures the correct workspace policy is resolved for selfDM track expenses.In
usePolicyForTransaction.ts: The current logic at line 51 only returnspolicyForSelfDMExpensefor unreported expenses (transaction.reportID === UNREPORTED_REPORT_ID) or creating track expenses (action === CREATE && iouType === TRACK). SelfDM expenses being edited may not meet either condition. The condition should also cover editing track expenses in selfDM (whenaction === EDITand the expense is in selfDM).What alternative solutions did you explore? (Optional)
An alternative would be to pass
policyForMovingExpensesthrough thegetUpdatedTransaction()call chain inTransactionUtils/index.ts(lines 726, 777, 863 all callgetRate()withoutpolicyForMovingExpenses). However, fixing the policy resolution at the component level is a cleaner approach since it addresses the root cause — the wrong policy being passed into the entire save flow — rather than patching individual call sites.Confidence: High — the evidence chain is complete from policy resolution → rate lookup → unit fallback → wrong save data. The rate editing page (
IOURequestStepDistanceRate.tsx) already demonstrates the correct pattern at line 66.Relevant Code:
src/pages/iou/request/step/IOURequestStepDistanceManual.tsx:76— usesusePolicy(report?.policyID)(wrong for selfDM)src/pages/iou/request/step/IOURequestStepDistance.tsx:91— same issuesrc/pages/iou/request/step/IOURequestStepDistanceRate.tsx:66— usesusePolicyForTransaction(correct pattern)src/hooks/usePolicyForTransaction.ts:47-51— condition needs to cover selfDM edit casesrc/libs/DistanceRequestUtils.ts:372-374—getDistanceUnitfallback to miles when policy is nullNext Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.29 remaining items
cristipaval commentedon Mar 4, 2026
Closing this since it is a backend issue. I created a separate backend issue to fix this.
IuliiaHerets commentedon Mar 4, 2026
Chrome / v9.3.30-1
Distance unit stays personal when create track distance expense in Self DM
Screen.Recording.2026-03-04.at.12.37.20.mp4
melvin-bot commentedon Mar 4, 2026
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.
If a regression has occurred and you are the assigned CM follow the instructions here.
If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.
[-][$250] Distance - Distance unit and rate change after editing distance[/-][+][Due for payment 2026-03-13] [$250] Distance - Distance unit and rate change after editing distance[/+]melvin-bot commentedon Mar 6, 2026
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Mar 6, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.31-12 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-03-13. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Mar 6, 2026
@parasharrajat / @FitseTLT @heyjennahay The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
melvin-bot commentedon Mar 6, 2026
Current assignee @heyjennahay is eligible for the Awaiting Payment assigner, not assigning anyone new.