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 - Old unit persists when splitting distance after changing distance unit #83485
Version Number: 9.3.26-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:#82257 Email or phone of affected tester (no customers):sdjsiodjsnodjsonjsio@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
Create a workspace.
Go to workspace settings > More features.
Enable Distance rates.
Go to workspace settings > Distance rates.
Click Settings > Unit > change to Kilometers.
Go to workspace chat.
Create a manual distance expense.
Open the expense.
Click More > Split.
Click any split row.
→ Distance and Rate row still show miles after changing unit to kilometers.
Click Distance.
→ Distance editor shows converted distance in kilometers.
Click Save.
→ Distance is changed but the unit remains the same.
Expected Result:
In Step 11, Distance and Rate row will show kilometers because distance unit is changed to kilometers in Step 6.
In Step 13, Distance will update to kilometers together with the rate.
Actual Result:
In Step 11, Distance and Rate row still show miles after changing unit to kilometers.
In Step 13, Distance is changed but the unit is still miles.
👋 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: #82257 - "feat: handle the Distance and Rate fields for splits" by @ZhenjaHorbach (High confidence) Related Issues: None
Recommendation: REVERT
The PR introduced a bug in the split distance expense flow where the distance unit is not updated when creating split expenses. When a workspace distance rate is changed from miles to kilometers, the split expenses still display the old unit (miles) instead of the updated unit (kilometers).
Labels: No label changes made. The issue correctly has DeployBlockerCash since this is a frontend bug that requires an App PR to fix.
📋 Detailed Analysis
Evidence
PR #82257 added comprehensive support for distance and rate fields in split expenses. The bug was introduced in the updateSplitExpenseDistanceFromAmount function in /home/runner/_work/App/App/src/libs/actions/IOU/Split.ts.
The reproduction steps clearly show:
User creates a workspace and enables distance rates
Changes the distance unit from miles to kilometers in workspace settings
Creates a distance expense and splits it
The split expense rows incorrectly show miles instead of kilometers
Verification
The causing PR modifies several distance-related files:
The PR was merged on 2026-02-24 and is included in staging deploy 9.3.26-0, matching the version where the bug was reported.
Root Cause
In src/libs/actions/IOU/Split.ts, the function updateSplitExpenseDistanceFromAmount (lines 1890-1915):
functionupdateSplitExpenseDistanceFromAmount(amount: number,rate: number,unit: Unit|undefined,// This is the CORRECT unit from the policy (kilometers)existingCustomUnit: TransactionCustomUnit|undefined,// This has the OLD unit (miles)mileageRate: {currency?: string},transactionCurrency?: string,): {customUnit: TransactionCustomUnit|undefined;merchant: string}{// ...constcustomUnit: TransactionCustomUnit={
...existingCustomUnit,// Spreads old customUnit with distanceUnit: "mi"
quantity,// Only updates quantity, NOT distanceUnit};// The "unit" parameter is used for merchant calculation but NOT saved to customUnit.distanceUnitconstmerchant=getDistanceMerchantFromDistance(distanceInUnits,unit,rate, ...);return{customUnit, merchant};}
The function receives the correct unit from the policy (kilometers) but only uses it to calculate the merchant string. It spreads existingCustomUnit which contains the old distanceUnit: "mi" from the original transaction, without updating it to the new unit.
The fix would be to update line 1907-1910 to:
constcustomUnit: TransactionCustomUnit={
...existingCustomUnit,
quantity,distanceUnit: unit,// Add this line};
changed the title [-]Distance - Old unit persists when splitting distance after changing distance unit[/-][+][$250] Distance - Old unit persists when splitting distance after changing distance unit[/+]on Feb 25, 2026
Please re-state the problem that we are trying to solve in this issue.
After changing the workspace distance unit from miles to kilometers, splitting a distance expense still shows the old unit (miles) in each split row's Distance and Rate fields.
What is the root cause of that problem?
In src/libs/TransactionUtils/index.ts (buildOptimisticTransaction, ~line 511), when customUnit is provided (the split expense path), it is set on the transaction verbatim without updating distanceUnit:
if (customUnit) {
lodashSet(commentJSON, 'customUnit', customUnit);
}
The else branch (non-split path at line 515) correctly calls DistanceRequestUtils.getUpdatedDistanceUnit({transaction, policy}) to get the current policy unit. But the split path skips this entirely, so each split inherits the original transaction's stale distanceUnit (e.g. mi) even though the policy now uses km.
What changes do you think we should make in order to solve the problem?
In buildOptimisticTransaction in src/libs/TransactionUtils/index.ts, after setting customUnit from the provided parameter (~line 512), also update customUnit.distanceUnit to the current policy unit by calling DistanceRequestUtils.getUpdatedDistanceUnit({transaction: existingTransaction, policy}). This ensures split transactions pick up the workspace's current distance unit setting rather than preserving the stale unit from the original transaction.
The quantity (distance value) should also be converted from the old unit to the new unit when the units differ (e.g. miles → km), using the existing conversion logic in DistanceRequestUtils, so the displayed distance is correct in the new unit.
What alternative solutions did you explore? (Optional)
Updating the distanceUnit at the call site in src/libs/actions/IOU/Split.ts (where splitExpense.customUnit is assembled) was considered, but fixing it in buildOptimisticTransaction is more centralized and prevents the same stale-unit bug from occurring in any other code path that passes customUnit directly.
Activity
melvin-bot commentedon Feb 25, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #82257
melvin-bot commentedon Feb 25, 2026
💬 A slack conversation has been started in #expensify-open-source
melvin-bot commentedon Feb 25, 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 Feb 25, 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 Feb 25, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #82257 - "feat: handle the Distance and Rate fields for splits" by @ZhenjaHorbach (High confidence)
Related Issues: None
Recommendation: REVERT
The PR introduced a bug in the split distance expense flow where the distance unit is not updated when creating split expenses. When a workspace distance rate is changed from miles to kilometers, the split expenses still display the old unit (miles) instead of the updated unit (kilometers).
Labels: No label changes made. The issue correctly has
DeployBlockerCashsince this is a frontend bug that requires an App PR to fix.📋 Detailed Analysis
Evidence
PR #82257 added comprehensive support for distance and rate fields in split expenses. The bug was introduced in the
updateSplitExpenseDistanceFromAmountfunction in/home/runner/_work/App/App/src/libs/actions/IOU/Split.ts.The reproduction steps clearly show:
Verification
The causing PR modifies several distance-related files:
src/libs/actions/IOU/Split.ts- Core split logicsrc/pages/iou/SplitExpenseEditPage.tsx- Split expense UIsrc/libs/TransactionUtils/index.ts- Transaction utilitiesThe PR was merged on 2026-02-24 and is included in staging deploy 9.3.26-0, matching the version where the bug was reported.
Root Cause
In
src/libs/actions/IOU/Split.ts, the functionupdateSplitExpenseDistanceFromAmount(lines 1890-1915):The function receives the correct
unitfrom the policy (kilometers) but only uses it to calculate the merchant string. It spreadsexistingCustomUnitwhich contains the olddistanceUnit: "mi"from the original transaction, without updating it to the new unit.The fix would be to update line 1907-1910 to:
lakchote commentedon Feb 25, 2026
cc @ZhenjaHorbach comes from #78891
5 remaining items
[-]Distance - Old unit persists when splitting distance after changing distance unit[/-][+][$250] Distance - Old unit persists when splitting distance after changing distance unit[/+]melvin-bot commentedon Feb 25, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022026758698186474494
melvin-bot commentedon Feb 26, 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.
melvin-bot commentedon Feb 26, 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.
Pujan92 commentedon Feb 26, 2026
@lakchote Plz unassign me here and assign it to @ZhenjaHorbach
m-natarajan commentedon Feb 26, 2026
Not Repro, Windows 10/ Chrome, v9.3.26-6
repro.-.issue.83485.mp4
yifangoh commentedon Feb 26, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After changing the workspace distance unit from miles to kilometers, splitting a distance expense still shows the old unit (miles) in each split row's Distance and Rate fields.
What is the root cause of that problem?
In
src/libs/TransactionUtils/index.ts(buildOptimisticTransaction, ~line 511), whencustomUnitis provided (the split expense path), it is set on the transaction verbatim without updatingdistanceUnit:The
elsebranch (non-split path at line 515) correctly callsDistanceRequestUtils.getUpdatedDistanceUnit({transaction, policy})to get the current policy unit. But the split path skips this entirely, so each split inherits the original transaction's staledistanceUnit(e.g.mi) even though the policy now useskm.What changes do you think we should make in order to solve the problem?
In
buildOptimisticTransactioninsrc/libs/TransactionUtils/index.ts, after settingcustomUnitfrom the provided parameter (~line 512), also updatecustomUnit.distanceUnitto the current policy unit by callingDistanceRequestUtils.getUpdatedDistanceUnit({transaction: existingTransaction, policy}). This ensures split transactions pick up the workspace's current distance unit setting rather than preserving the stale unit from the original transaction.The
quantity(distance value) should also be converted from the old unit to the new unit when the units differ (e.g. miles → km), using the existing conversion logic inDistanceRequestUtils, so the displayed distance is correct in the new unit.What alternative solutions did you explore? (Optional)
Updating the
distanceUnitat the call site insrc/libs/actions/IOU/Split.ts(wheresplitExpense.customUnitis assembled) was considered, but fixing it inbuildOptimisticTransactionis more centralized and prevents the same stale-unit bug from occurring in any other code path that passescustomUnitdirectly.lakchote commentedon Mar 3, 2026
Closing it as it's not repro