Skip to content

[Due for payment 2026-05-22] [$250] Expense - "Rate not valid for this workspace" error, reappears after selecting a valid rate. #84238

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.31.0
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-7606/folder/13176670/41237108/1228588679
Email or phone of affected tester (no customers): ibellicotest+2250@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 11 / Chrome
App Component: Money Requests

Action Performed:

Prerequisite: Account has at least one workspace with "Rules" enabled.
Prerequisite 2: Account has Self DM.

  1. Open the staging.new.expensify.com website.
  2. Navigate to Self DM.
  3. Create a map distance expense.
  4. Open the just created expense.
  5. Tap on report field and select a workspace to move the expense to.
  6. Navigate to workspace and open expense report.
  7. Note that a "Rate not valid for this workspace" error message appears.
  8. Open "Rate" field and select any valid rate.
  9. Note that error and RBR are cleared.
  10. Return to chat.
  11. Note that after some seconds, RBR and "Rate not valid for this workspace" error message reappear.

Expected Result:

"Rate not valid for this workspace" error message should disappear after selecting a valid rate and should not reappear after some time.

Actual Result:

"Rate not valid for this workspace" error message and RBR reappear after seleting a valid rate for distance expense.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7094259_1772677983345.Not_Valid.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/~022043666502744366749
  • Upwork Job ID: 2043666502744366749
  • Last Price Increase: 2026-04-13

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    and removed on Apr 13, 2026
  2. MelvinBot commented on Apr 13, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    Race condition between two sequential API calls: CHANGE_TRANSACTIONS_REPORT (move) and UPDATE_MONEY_REQUEST_DISTANCE_RATE (rate selection).

    When a distance expense is moved from Self DM to a workspace, changeTransactionsReport (Transaction.ts:1046-1058) updates the reportID but does not update the customUnitRateID — it stays as the Self DM P2P rate (e.g. _FAKE_P2P_ID_). The optimistic violation check at ViolationsUtils.ts:421-434 correctly detects this as invalid and adds CUSTOM_UNIT_OUT_OF_POLICY.

    When the user then selects a valid rate, updateMoneyRequestDistanceRate (UpdateMoneyRequest.ts:650-723) optimistically clears the violation. However, changeTransactionsReport has no successData for transaction violations (Transaction.ts:1060-1067), so the backend's Pusher response delivers its own violation calculations — computed with the original stale P2P rate — which overwrites the optimistic clear from the rate update, making the error reappear.

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

    In changeTransactionsReport, when moving a distance expense to a workspace, auto-select a valid default rate for the destination workspace and update the transaction's customUnitRateID in the optimistic data. This mirrors what the backend should do and prevents the stale P2P rate from persisting.

    Specifically, in Transaction.ts around the optimistic data for the move:

    1. Detect when the transaction is a distance request and the destination is a paid group policy
    2. Check if the current customUnitRateID is valid for the destination policy (using getDistanceRateCustomUnitRate)
    3. If not valid, find the workspace's default distance rate and include the updated customUnitRateID in the optimistic transaction data and in the API params sent to the backend
    4. This ensures the violation check in ViolationsUtils.getViolationsOnyxData uses the corrected rate, and the backend processes the move with the correct rate from the start — eliminating the race condition entirely

    What alternative solutions did you explore? (Optional)

    An alternative would be to add successData for transaction violations in changeTransactionsReport that nullifies the violations so they get re-fetched from the server after the full queue processes. However, this only masks the timing issue and doesn't fix the underlying problem that the rate stays invalid after a move. Auto-selecting a valid rate at move time is the more correct fix since it addresses the actual data inconsistency.

    Investigation details

    Race condition timeline:

    1. CHANGE_TRANSACTIONS_REPORT sent (transaction still has P2P rate)
    2. Client shows "Rate not valid" violation (correct)
    3. User picks valid rate
    4. UPDATE_MONEY_REQUEST_DISTANCE_RATE sent, optimistically clears violation
    5. Backend response from step 1 arrives via Pusher with stale violations (still showing invalid rate) — overwrites step 4's optimistic update
    6. Violation reappears
    7. Eventually backend response from step 4 arrives and clears it

    Key code paths:

    Possibly related open issues:


    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.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 13, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 13, 2026
  5. melvin-bot commented on Apr 13, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @ShridharGoel (External)

  6. 32 remaining items

  7. melvin-bot commented on May 21, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  8. ShridharGoel commented on May 22, 2026

    @ShridharGoel
    Contributor

    @MelvinBot Find the PR which caused this bug

  9. MelvinBot commented on May 22, 2026

    @MelvinBot
    Contributor

    PR Expensify/App#73101 ("Unreported Expense - Category field") by koko57, merged October 22, 2025.

    A commit in that PR added && !isSelfDM to the customUnitOutOfPolicy validation block in ViolationsUtils.ts:422. This guard causes the entire custom-unit-rate violation logic to be skipped when isSelfDM is true — so when a distance expense originates in Self DM and is later moved to a workspace, the CUSTOM_UNIT_OUT_OF_POLICY violation can never be cleared client-side, even after the user selects a valid rate.

    Details
    • PR Expensify/App#72457 (merged Oct 16, 2025) first introduced the isSelfDM parameter to getViolationsOnyxData, but only used it for category violations (missingCategory).
    • PR Expensify/App#73101 (merged Oct 22, 2025) extended the !isSelfDM guard to the customUnitOutOfPolicy block, inadvertently breaking distance-rate violation clearing for expenses moved from Self DM.
    • The diff: - if (customUnitRateID && customUnitRateID.length > 0) { → + if (customUnitRateID && customUnitRateID.length > 0 && !isSelfDM) {
  10. ShridharGoel commented on May 22, 2026

    @ShridharGoel
    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: Unreported Expense - Category field #73101 (comment)
      Link to the comment on the Issue:

    • [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/640662

    Regression Test Proposal

    Precondition:

    Have self DM and a workspace. Workspace should have at least some distance rates which are different from the personal space's distance rates.

    Test:

    1. Open Expensify.
    2. Navigate to Self DM.
    3. Create a map distance expense.
    4. Open the just created expense.
    5. Tap on report field and select a workspace to move the expense to.
    6. Navigate to workspace and open expense report.
    7. Note that a "Rate not valid for this workspace" error message appears.
    8. Open "Rate" field and select any valid rate.
    9. Note that error and RBR are cleared.
    10. Return to chat.
    11. The rate not valid error should not show even after waiting for few seconds.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-73d3-af6c-3eae-832667dab5d4
  11. melvin-bot commented on May 22, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2043666502744366749/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  12. mallenexpensify commented on May 25, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @ShridharGoel due $250 via NewDot

    ^ Test case created. Thx

  13. garrettmknight commented on May 28, 2026

    @garrettmknight
    Contributor

    $250 approved for @ShridharGoel

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