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
Distance - Distance field shows new unit instead of original unit after changing distance unit #84195
Version Number: 9.3.31-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:#79638 Email or phone of affected tester (no customers):osdjosjdnodnjoijso@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:
Enable Distance rates in workspace settings > More features.
Go to staging.new.expensify.com
Go to workspace chat.
Create a manual distance expense.
Go to workspace settings > Distance rates.
Click Settings > Unit.
Change to another unit.
Open the distance expense from Step 3.
→ Distance field shows the new unit instead of the original unit.
Click Distance.
→ Distance field in Step 7 shows the new unit. Distance editor further converts to the same unit.
Expected Result:
In Step 7, Distance field will show the original unit.
Actual Result:
In Step 7, Distance field shows the new unit instead of the original unit.
In Step 8, Distance editor further converts to the same unit.
👋 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: #79638 - "Fix distance unit not updating on workspace switch" by @marufsharifi (High confidence) Related Issues: #78212 (issue that PR #79638 was fixing)
Recommendation: REVERT
PR #79638 fixed one issue (unit not updating when switching between workspaces) but introduced a regression where changing a workspace distance unit setting causes existing distance expenses to immediately display the new unit instead of preserving their original unit at creation time.
Labels: This is a frontend bug caused by an App PR. Keeping DeployBlockerCash label. The DeployBlocker label was not present on this issue.
📋 Detailed Analysis
Evidence
PR #79638 modified the getDistanceUnit() function in src/libs/DistanceRequestUtils.ts which directly affects how distance units are displayed for transactions. The change was merged on 2026-03-04 and is included in the current staging deploy (9.3.31-0).
The issue reproduction steps match exactly what the code change would cause:
Create a manual distance expense (stores the current unit, e.g., miles)
Change workspace distance unit settings (changes the mileage rate unit to km)
View the distance expense - it now shows km instead of the original miles
Verification
Files affected by the bug:
src/libs/DistanceRequestUtils.ts - contains getDistanceUnit() function
src/pages/iou/request/step/IOURequestStepDistanceRate.tsx - uses getDistanceUnit() to display distance units (line 100, 132)
PR #79638 modifies DistanceRequestUtils.ts and its test file, confirming it touches the exact code path responsible for this issue.
The problem: The new logic only returns the transaction unit if it matches the current rate unit. When a workspace admin changes the distance unit setting:
Existing transactions have the old unit stored (e.g., miles)
The new mileage rate has the new unit (e.g., km)
Since they do not match, the function returns the new rate unit instead of preserving the original transaction unit
This causes the distance field to display the wrong unit and convert the value incorrectly
PR #79638 was intended to fix issue #78212 (unit not updating when switching workspaces), but it went too far and now causes units to update even when they should not (when viewing a historical transaction after changing workspace settings).
Please re-state the problem that we are trying to solve in this issue.
After changing the distance unit in workspace settings (e.g., miles → km), existing distance expenses retroactively display the new unit instead of the original unit they were created with. Opening the distance editor further converts the value to the new unit.
What is the root cause of that problem?
PR #79638 changed the getDistanceUnit function in src/libs/DistanceRequestUtils.ts (lines 396-405). The old code used a simple nullish coalescing fallback that always preferred the transaction's stored unit:
When the workspace admin changes the distance unit (e.g., miles → km), the stored transaction unit (mi) no longer matches the policy's current rate unit (km), so the equality check fails and the function returns the policy's new unit instead of the transaction's original unit. This wrong unit then flows through MoneyRequestView.tsx (line 420) and the distance editors, causing the display and conversion issues.
What changes do you think we should make in order to solve the problem?
Revert getDistanceUnit to prefer the transaction's stored distanceUnit when it exists, regardless of whether it matches the policy's current rate unit. The function should return to the simple fallback chain: transaction unit first, then rate unit, then the default (miles).
The original problem that PR #79638 was solving (unit not updating on workspace switch during creation) should instead be handled by the callers — specifically by passing useTransactionDistanceUnit: false in the workspace-switching creation flow, rather than changing the core getDistanceUnit logic that affects all existing expense displays.
What alternative solutions did you explore? (Optional)
An alternative would be to add a separate code path in getDistanceUnit that distinguishes "viewing an existing expense" from "creating/editing and switching workspaces." However, this distinction is already handled by the useTransactionDistanceUnit parameter on getRate() — when it's false, getDistanceUnit receives undefined for the transaction and naturally falls back to the rate unit. The simpler revert is the cleaner fix.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
@marufsharifi I'm going to revert your PR for now to resolve this deploy blocker. Please raise a follow-up PR for the original issue later with this regression in mind.
Activity
melvin-bot commentedon Mar 4, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #79638
melvin-bot commentedon Mar 4, 2026
💬 A slack conversation has been started in #expensify-open-source
melvin-bot commentedon Mar 4, 2026
Triggered auto assignment to @johncschuster (
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 4, 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 4, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #79638 - "Fix distance unit not updating on workspace switch" by @marufsharifi (High confidence)
Related Issues: #78212 (issue that PR #79638 was fixing)
Recommendation: REVERT
PR #79638 fixed one issue (unit not updating when switching between workspaces) but introduced a regression where changing a workspace distance unit setting causes existing distance expenses to immediately display the new unit instead of preserving their original unit at creation time.
Labels: This is a frontend bug caused by an App PR. Keeping
DeployBlockerCashlabel. TheDeployBlockerlabel was not present on this issue.📋 Detailed Analysis
Evidence
PR #79638 modified the
getDistanceUnit()function insrc/libs/DistanceRequestUtils.tswhich directly affects how distance units are displayed for transactions. The change was merged on 2026-03-04 and is included in the current staging deploy (9.3.31-0).The issue reproduction steps match exactly what the code change would cause:
Verification
Files affected by the bug:
src/libs/DistanceRequestUtils.ts- containsgetDistanceUnit()functionsrc/pages/iou/request/step/IOURequestStepDistanceRate.tsx- usesgetDistanceUnit()to display distance units (line 100, 132)PR #79638 modifies
DistanceRequestUtils.tsand its test file, confirming it touches the exact code path responsible for this issue.Root Cause
Original logic (before PR #79638):
This would always prefer the transaction stored unit if present.
New logic (after PR #79638):
The problem: The new logic only returns the transaction unit if it matches the current rate unit. When a workspace admin changes the distance unit setting:
PR #79638 was intended to fix issue #78212 (unit not updating when switching workspaces), but it went too far and now causes units to update even when they should not (when viewing a historical transaction after changing workspace settings).
MelvinBot commentedon Mar 4, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After changing the distance unit in workspace settings (e.g., miles → km), existing distance expenses retroactively display the new unit instead of the original unit they were created with. Opening the distance editor further converts the value to the new unit.
What is the root cause of that problem?
PR #79638 changed the
getDistanceUnitfunction insrc/libs/DistanceRequestUtils.ts(lines 396-405). The old code used a simple nullish coalescing fallback that always preferred the transaction's stored unit:The new code only returns the transaction's stored unit if it equals the policy's current rate unit:
When the workspace admin changes the distance unit (e.g., miles → km), the stored transaction unit (
mi) no longer matches the policy's current rate unit (km), so the equality check fails and the function returns the policy's new unit instead of the transaction's original unit. This wrong unit then flows throughMoneyRequestView.tsx(line 420) and the distance editors, causing the display and conversion issues.What changes do you think we should make in order to solve the problem?
Revert
getDistanceUnitto prefer the transaction's storeddistanceUnitwhen it exists, regardless of whether it matches the policy's current rate unit. The function should return to the simple fallback chain: transaction unit first, then rate unit, then the default (miles).The original problem that PR #79638 was solving (unit not updating on workspace switch during creation) should instead be handled by the callers — specifically by passing
useTransactionDistanceUnit: falsein the workspace-switching creation flow, rather than changing the coregetDistanceUnitlogic that affects all existing expense displays.What alternative solutions did you explore? (Optional)
An alternative would be to add a separate code path in
getDistanceUnitthat distinguishes "viewing an existing expense" from "creating/editing and switching workspaces." However, this distinction is already handled by theuseTransactionDistanceUnitparameter ongetRate()— when it'sfalse,getDistanceUnitreceivesundefinedfor the transaction and naturally falls back to the rate unit. The simpler revert is the cleaner fix.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.inimaga commentedon Mar 5, 2026
@marufsharifi I'm going to revert your PR for now to resolve this deploy blocker. Please raise a follow-up PR for the original issue later with this regression in mind.
cc: @mananjadhav
m-natarajan commentedon Mar 5, 2026
Chrome / v9.3.31-5
Distance field shows original unit.
Distance editor shows new unit.
Screen.Recording.2026-03-05.at.17.56.47.mp4
inimaga commentedon Mar 5, 2026
Thanks for confirming.