Skip to content

[Due for payment 2026-09-16] Each US distance rate appears twice after copying distance rates from USD workspace #99285

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.59-1
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: #97936
Email or phone of affected tester (no customers): sjodijsnonjioidosjiji@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • Create a USD workspace.
  • Enable Distance rates.
  • Enable Auto-update government rates in Distance rates > Settings.
  1. Go to staging.new.expensify.com
  2. Create a non-USD workspace.
  3. Go to workspace settings > More features.
  4. Enable Distance rates.
  5. Go back to workspace list.
  6. Click 3-dot menu on USD workspace > Copy settings.
  7. Select the non-USD workspace in Step 2 > Next.
  8. Select Distance rates > Next > Copy settings.
  9. Wait for copy to complete.
  10. Go to non-USD workspace settings > Distance rates.

Expected Result:

Each US distance rate will appear only once because source has one expired rate and one active rate while non-USD workspace has neither of the rates.

Actual Result:

Each US distance rate appears twice after copying settings from USD workspace to non-USD workspace.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7240159_1787416960632.11.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7240159

Issue OwnerCurrent Issue Owner: @Krishna2323

Activity

  1. applause-bot commented on Aug 24, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/ff7932208c205706b8a2e8fe1605cf41da6fc32a2f048b3657e9f9417ab39aa0

  2. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 24, 2026
  3. melvin-bot commented on Aug 24, 2026

    @melvin-bot

    @neil-marcellini recently merged #97936, but they are OOO right now, so I'll auto-assign someone else.

  4. melvin-bot commented on Aug 24, 2026

    @melvin-bot

    Triggered auto assignment to @grgia (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  5. melvin-bot commented on Aug 24, 2026

    @melvin-bot

    @neil-marcellini @thelullabyy you have been assigned to this deploy blocker because you reviewed the offending PR: #97936

  6. melvin-bot commented on Aug 24, 2026

    @melvin-bot

    @Krishna2323 you have been assigned to this deploy blocker because you authored the offending PR: #97936

  7. melvin-bot commented on Aug 24, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  8. 11 remaining items

  9. neil-marcellini commented on Sep 1, 2026

    @neil-marcellini
    Contributor

    (Neil's AI agent)

    A nuance worth spelling out, because it's easy to read the copy code and conclude that only pre-existing rates can duplicate.

    Auth re-keys every rate it copies, not just the ones it can match to the target. From copyCustomUnitPreservingIDs:

    const string rateName = rate.getStringMemberWithDefault("name");
    const auto existing = targetRateIDByName.find(rateName);
    if (existing != targetRateIDByName.end()) {
        rate["customUnitRateID"] = JSON::Value(existing->second);
    } else {
        rate["customUnitRateID"] = JSON::Value(PolicyCustomUnit::generateID());
    }

    A source rate with no name match on the target doesn't keep the source's customUnitRateID — it gets a freshly generated one. The source rate ID never survives the copy either way. The unit ID works the same when the target has no distance unit at all.

    So both kinds of rate duplicate, for the same reason: the client holds the rate under the source's ID, the server persists it under a different one, and the push is an Onyx merge of customUnits keyed by rate ID, so nothing removes the client's copy.

    That matches what was reported: the target workspace had neither US rate, so those were the new rates — and they're the ones that showed up twice.

    This is why the draft PR has two halves rather than one:

    1. Source rate whose name is already on the target → write it under the target's rate ID. This mirrors Auth exactly and covers the rates the target already had.
    2. Source rate with no name match (and the whole unit when the target has none) → leave it out of the optimistic patch. The client can't reproduce generateID(), so any ID it invents becomes a second row when the push lands. Those rates appear when the server response arrives instead.

    The alternative for (2) is to send client-generated rate IDs to the backend and have Auth persist them — the pattern setWorkspaceDistanceAutoUpdate already uses, which exists for exactly this reason. That keeps the instant preview for brand-new rates, at the cost of an Auth change plus a per-target ID map for multi-target copies.

  10. neil-marcellini commented on Sep 1, 2026

    @neil-marcellini
    Contributor

    I'll move ahead with only the App PR. We don't need optimistic updates for the new rates because the app does the copying under a blocking modal.

  11. added
    ReviewingHas a PR in review
    and removed on Sep 3, 2026
  12. neil-marcellini commented on Sep 8, 2026

    @neil-marcellini
    Contributor

    Fix is on staging, will be done soon

  13. added and removed
    ReviewingHas a PR in review
    on Sep 9, 2026
  14. changed the title [-]Each US distance rate appears twice after copying distance rates from USD workspace[/-] [+][Due for payment 2026-09-16] Each US distance rate appears twice after copying distance rates from USD workspace[/+] on Sep 9, 2026
  15. melvin-bot commented on Sep 9, 2026

    @melvin-bot

    @Krishna2323 / @thelullabyy

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.74-2 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-09-16. 🎊

    The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ 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]. If no checklist is needed for this issue, you can click: [no checklist button]

  16. Krishna2323 commented on Sep 10, 2026

    @Krishna2323
    Contributor

    @neil-marcellini, I think we can close this issue. Payments will be handled centrally for the project.

    I have added this issue here: https://github.com/orgs/Expensify/projects/276/views/1

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions