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-15] [$250] Expense - In duplicate workspace, creating distance manual expense shows unexpected error. #86116
When a workspace is duplicated, the duplication feature form only shows the "Distance Rates" option if the source workspace has areDistanceRatesEnabled: true (WorkspaceDuplicateSelectFeaturesForm.tsx:150-156). However, newly created workspaces have areDistanceRatesEnabled: false by default — even though they still have a default distance custom unit in customUnits.
Because the option isn't shown, isDistanceRatesOptionSelected is false, and getCustomUnitsForDuplication returns undefined. The optimistic policy data then sets customUnits: undefined on the duplicated policy via Onyx.METHOD.SET (Policy.ts:~3160).
When the user creates a distance expense in the duplicated workspace, getDefaultMileageRate returns undefined (no customUnits), so getCustomUnitRateID falls back to FAKE_P2P_ID. The backend rejects the CreateDistanceRequest because FAKE_P2P_ID is not a valid rate for the duplicated workspace, producing the "Unexpected error submitting this expense" message.
What changes do you think we should make in order to solve the problem?
In getCustomUnitsForDuplication (PolicyUtils.ts), the distance custom unit should always be copied to the duplicated policy when the source policy has one — regardless of whether isDistanceRatesOptionSelected is true. Every workspace needs a default distance unit for distance expenses to work, even if the distance rates feature toggle is off.
Specifically, the early return at PolicyUtils.ts:320 should not prevent distance unit copying when the source has a valid distance custom unit. The function should always include the distance custom unit in its return value when the source policy has one, gated only on whether the source policy actually has a distance unit (not on the user's feature selection).
What alternative solutions did you explore? (Optional)
An alternative would be to guard the distance expense creation UI so it's unavailable when customUnits is empty. However, this would be a workaround — the real issue is that workspace duplication should preserve the default distance unit since it's required for basic workspace functionality.
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.
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.68-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@hoangzinh 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]
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Activity
Fix custom unit ID mismatch when duplicating workspace
MelvinBot commentedon Apr 13, 2026
Proposal
What is the root cause of that problem?
When a workspace is duplicated, the duplication feature form only shows the "Distance Rates" option if the source workspace has
areDistanceRatesEnabled: true(WorkspaceDuplicateSelectFeaturesForm.tsx:150-156). However, newly created workspaces haveareDistanceRatesEnabled: falseby default — even though they still have a default distance custom unit incustomUnits.Because the option isn't shown,
isDistanceRatesOptionSelectedisfalse, andgetCustomUnitsForDuplicationreturnsundefined. The optimistic policy data then setscustomUnits: undefinedon the duplicated policy viaOnyx.METHOD.SET(Policy.ts:~3160).When the user creates a distance expense in the duplicated workspace,
getDefaultMileageRatereturnsundefined(nocustomUnits), sogetCustomUnitRateIDfalls back toFAKE_P2P_ID. The backend rejects theCreateDistanceRequestbecauseFAKE_P2P_IDis not a valid rate for the duplicated workspace, producing the "Unexpected error submitting this expense" message.What changes do you think we should make in order to solve the problem?
In
getCustomUnitsForDuplication(PolicyUtils.ts), the distance custom unit should always be copied to the duplicated policy when the source policy has one — regardless of whetherisDistanceRatesOptionSelectedis true. Every workspace needs a default distance unit for distance expenses to work, even if the distance rates feature toggle is off.Specifically, the early return at
PolicyUtils.ts:320should not prevent distance unit copying when the source has a valid distance custom unit. The function should always include the distance custom unit in its return value when the source policy has one, gated only on whether the source policy actually has a distance unit (not on the user's feature selection).What alternative solutions did you explore? (Optional)
An alternative would be to guard the distance expense creation UI so it's unavailable when
customUnitsis empty. However, this would be a workaround — the real issue is that workspace duplication should preserve the default distance unit since it's required for basic workspace functionality.Possibly related 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.60 remaining items
melvin-bot commentedon May 8, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.68-3 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-05-15. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon May 8, 2026
@hoangzinh 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]
hoangzinh commentedon May 9, 2026
BugZero Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: https://github.com/Expensify/App/pull/71479/changes#r3241653948
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/637627
Regression Test Proposal
Test:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-85d6-abfb-5e55-1ad48c999234hoangzinh commentedon May 9, 2026
This issue has one DB here #89865
melvin-bot commentedon May 14, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)mallenexpensify commentedon May 16, 2026
Payment Summary
Contributor: @wildan-m paid $125 via Upwork
Contributor+: @hoangzinh due $125 via NewDot
^ Test case created
Thx
laurenreidexpensify commentedon May 19, 2026
$125 approved for @hoangzinh