Skip to content

[Due for payment 2026-04-14] [Due for payment 2026-03-13] [$250] Distance - To field changes from workspace to self DM after changing rate and submitting it #83955

Closed

Description

@mitarachim

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: 9.3.28-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: #81883
Email or phone of affected tester (no customers): isodjnosidjiojiojiso@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:

  • Workspace has at least two distance rates.
  1. Go to staging.new.expensify.com
  2. Go to self DM.
  3. Create a manual distance expense.
  4. Open the expense.
  5. Go offline.
  6. Click Rate and select another rate.
  7. Go back to self DM.
  8. Click Submit it to someone.
  9. Select workspace chat.
  10. On confirm page, go online.

Expected Result:

To field on confirm page will not change after returning online.

Actual Result:

To field on confirm page changes to self DM.
Amount is flipped.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7092358_1772491789006.3.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/~022028613855074606911
  • Upwork Job ID: 2028613855074606911
  • Last Price Increase: 2026-03-02
  • Automatic offers:
    • FitseTLT | Contributor | 110650049

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on Mar 2, 2026
  2. melvin-bot commented on Mar 2, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #81883

  3. melvin-bot commented on Mar 2, 2026

    @melvin-bot

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

  4. melvin-bot commented on Mar 2, 2026

    @melvin-bot

    Triggered auto assignment to @jliexpensify (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.

  5. github-actions commented on Mar 2, 2026

    @github-actions
    Contributor

    👋 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:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. MelvinBot commented on Mar 2, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user creates a manual distance expense in self-DM, opens it, goes offline, changes the rate, then initiates "Submit it to someone" and selects a workspace, the "To" field on the confirm page reverts from the selected workspace to self-DM when the user goes back online. The amount also flips sign.

    What is the root cause of that problem?

    The root cause is in getUpdateTrackExpenseParams (src/libs/actions/IOU/index.ts:5120-5126). When updating a distance rate (customUnitRateID in transactionChanges), the function includes in its successData an Onyx.METHOD.SET that clears TRANSACTION_DRAFT to null:

    if (transaction && updatedTransaction && (hasPendingWaypoints || hasModifiedDistanceRate)) {
        successData.push({
            onyxMethod: Onyx.METHOD.SET,
            key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`,
            value: null,
        });
    

    Here's the sequence that causes the bug:

    1. Offline: User changes distance rate → updateMoneyRequestDistanceRate queues UpdateMoneyRequestDistanceRate API call, whose successData includes clearing TRANSACTION_DRAFT to null
    2. Offline: User starts "Submit it to someone" flow → setMoneyRequestParticipantsFromReport writes workspace participants to the same TRANSACTION_DRAFT key
    3. Offline: User reaches confirm page — it reads from TRANSACTION_DRAFT (which has the workspace participant), showing correct "To" field
    4. Online: Sequential queue processes UpdateMoneyRequestDistanceRate → server responds → queued successData clears TRANSACTION_DRAFT to null
    5. Confirm page's transaction variable (at IOURequestStepConfirmation.tsx:150: optimisticTransaction ?? existingTransaction) now falls back to the real TRANSACTION, which has no workspace participant → "To" field reverts to self-DM

    The amount flip happens because getUpdateTrackExpenseParams calculates the amount with isFromExpenseReport: false (line 5099), storing a positive amount. The confirm page now reads this positive amount from the real transaction instead of the draft, and the sign is wrong for a workspace expense report context.

    What changes do you think we should make in order to solve the problem?

    In getUpdateTrackExpenseParams at src/libs/actions/IOU/index.ts:5120, change the condition from:

    if (transaction && updatedTransaction && (hasPendingWaypoints || hasModifiedDistanceRate))
    

    to:

    if (transaction && updatedTransaction && hasPendingWaypoints)
    

    Remove hasModifiedDistanceRate from the condition. The comment at line 5121 already says "Delete the draft transaction when editing waypoints" — the hasModifiedDistanceRate condition was added without considering that the same TRANSACTION_DRAFT key might be used by the "Submit it to someone" flow for storing workspace participants.

    The same change should be applied in getUpdateMoneyRequestParams at line 4578 for consistency, since the same pattern exists there.

    Distance rate changes don't require the draft to be cleared — the rate/amount updates are written directly to the real TRANSACTION in the optimistic data. The draft clearing was only needed for waypoint edits where the server recalculates distance fields.

    What alternative solutions did you explore?

    1. Merge instead of SET: Change the Onyx.METHOD.SET to Onyx.METHOD.MERGE with only distance-specific fields cleared. This preserves participants but is fragile — other draft fields could still cause issues.
    2. Check for active submit flow: Before clearing the draft, check if TRANSACTION_DRAFT has participants set (indicating a submit flow). This doesn't work because the successData is baked at the time API.write is called (before the submit flow starts), not at the time it's applied.
    3. Store participants separately: Move participant storage out of TRANSACTION_DRAFT into a separate Onyx key. This is architecturally cleaner but requires significant refactoring.

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  7. 38 remaining items

  8. shubham1206agra commented on Mar 13, 2026

    @shubham1206agra
    Contributor

    @jliexpensify This is part of #74967 regression.

  9. melvin-bot commented on Mar 13, 2026

    @melvin-bot

    📣 @shubham1206agra! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  10. jliexpensify commented on Mar 13, 2026

    @jliexpensify
    Contributor

    Cool, so no payments needed right? I can close this out?

  11. FitseTLT commented on Mar 13, 2026

    @FitseTLT
    Contributor

    Cool, so no payments needed right? I can close this out?

    Yeah this can be closed @jliexpensify

  12. melvin-bot commented on Mar 13, 2026

    @melvin-bot

    Issue is ready for payment but no BZ is assigned. @mallenexpensify you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

  13. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    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.

  14. jponikarchuk commented on Apr 7, 2026

    @jponikarchuk

    Deploy Blocker #87207 was identified to be related to the PR #84136 that attempted to fix this issue.

  15. changed the title [-][Due for payment 2026-03-13] [$250] Distance - To field changes from workspace to self DM after changing rate and submitting it[/-] [+][Due for payment 2026-04-14] [Due for payment 2026-03-13] [$250] Distance - To field changes from workspace to self DM after changing rate and submitting it[/+] on Apr 7, 2026
  16. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.53-7 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-04-14. 🎊

    For reference, here are some details about the assignees on this issue:

  17. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    @parasharrajat / @FitseTLT @mallenexpensify 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]

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.EngineeringExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions