Skip to content

[Due for payment 2026-05-15] [$250] Expense - In duplicate workspace, creating distance manual expense shows unexpected error. #86116

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: V9.3.42
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-8761/folder/18717689/49756688/1247680588
Email or phone of affected tester (no customers): dreamnitethedragon+yydyd373@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: redmi note10s android 13
App Component: Money Requests

Action Performed:

  1. Launch app with new gmail account
  2. Create workpace
  3. Duplicate workspace
  4. Open duplicate workspace chat
  5. Create distance manual expense

Expected Result:

In duplicate workspace, creating distance manual expense must not show unexpected error.

Actual Result:

In duplicate workspace, creating distance manual expense shows unexpected error.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Video.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022043742044145471134
  • Upwork Job ID: 2043742044145471134
  • Last Price Increase: 2026-04-27
  • Automatic offers:
    • wildan-m | Contributor | 111296098

Activity

  1. added a commit that references this issue on Apr 10, 2026
    7ddb521
  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    and removed on Apr 13, 2026
  3. MelvinBot commented on Apr 13, 2026

    @MelvinBot
    Contributor

    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 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.

    Possibly related issues
    • Expensify/App#84228 — Unexpected error after duplicating distance expense offline (related distance + duplication error path)
    • Expensify/App#87663 — Impossible to duplicate distance expense on Self DM

    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.

  4. 60 remaining items

  5. melvin-bot commented on May 8, 2026

    @melvin-bot

    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:

  6. melvin-bot commented on May 8, 2026

    @melvin-bot

    @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]

  7. hoangzinh commented on May 9, 2026

    @hoangzinh
    Contributor

    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:

    1. Sign in to any account.
    2. Create a workspace (Workspace 1) with distance-rates option
    3. From the workspace switcher, duplicate Workspace 1 and confirm the distance-rates option is selected.
    4. Open the duplicated workspace's chat.
    5. Tap the green "+" → Track expense → Distance.
    6. Enter a starting and ending location, tap Next, set a merchant, then tap Create.
    7. Verify the distance expense is created successfully

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-85d6-abfb-5e55-1ad48c999234
  8. hoangzinh commented on May 9, 2026

    @hoangzinh
    Contributor

    This issue has one DB here #89865

  9. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on May 14, 2026
  10. melvin-bot commented on May 14, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  11. mallenexpensify commented on May 16, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @wildan-m paid $125 via Upwork
    Contributor+: @hoangzinh due $125 via NewDot

    ^ Test case created

    Thx

  12. laurenreidexpensify commented on May 19, 2026

    @laurenreidexpensify
    Contributor

    $125 approved for @hoangzinh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions