Skip to content

Distance - No rate error on confirm page when submitting expense with invalid rate from self DM #87207

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: 9.3.53-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: #84136
Email or phone of affected tester (no customers): jsdjosidjiojisojio3@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:

  • Enable Distance rates.
  • 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. Go to workspace settings > Distance rates.
  5. Delete the rate in Step 3.
  6. Go back in self DM.
  7. Click Submit it to someone.
  8. Select workspace chat.
  9. Click Rate field on confirm page.

Expected Result:

"Rate not valid for this workspace. Please select an available rate from the workspace." error will show up because the rate is deleted.

Actual Result:

"Rate not valid for this workspace. Please select an available rate from the workspace." error does not show up when the rate is deleted.
It auto selects any rate that is available.

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: @FitseTLT

Activity

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

    @melvin-bot

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

  3. melvin-bot commented on Apr 7, 2026

    @melvin-bot

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

  4. github-actions commented on Apr 7, 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.
  5. OSBotify commented on Apr 7, 2026

    @OSBotify
    Contributor

    Investigation Summary: Classification: Frontend bug. Causing PR: 84136 (Feat - Add distance rate to distance expenses tracked in selfDM) by FitseTLT - High confidence. Recommendation: REVERT. PR 84136 introduced a change to MoneyRequestConfirmationList.tsx that causes the app to silently auto-select a matching rate instead of showing the Rate not valid error when a previously-selected distance rate has been deleted from the workspace. Evidence: melvin-bot assigned PR 84136 as the causing PR. PR 84136 was merged 2026-04-06 and is in StagingDeployCash for version 9.3.53-1, matching the bug report. Bug is staging-only. Verification: The affected code path is in src/components/MoneyRequestConfirmationList.tsx lines 527-552, which PR 84136 directly modifies. Root cause: PR 84136 added a fallback in the useEffect that validates distance rates. When the original selected rate is deleted from the workspace, the code now checks for a matchingRate by value and unit, and if found, silently auto-selects it and clears the error instead of displaying the Rate not valid for this workspace error. Labels: Keeping DeployBlockerCash since this is a Frontend bug caused by an App PR.

  6. MelvinBot commented on Apr 7, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    PR #84136 assigns real rate IDs (from the personal policy) to distance expenses tracked in self DM. When the user later submits the expense to a workspace chat, the confirm page runs a validation useEffect (MoneyRequestConfirmationList.tsx:527-566) that checks if the transaction's rate ID exists in the workspace policy. When it doesn't find it, instead of showing the error, it:

    1. Calls getRate() (DistanceRequestUtils.ts:430-432) which falls back to the workspace's defaultMileageRate for non-unreported expenses
    2. Finds a workspace rate matching by value+unit (line 544)
    3. Auto-selects that matching rate and clears the error (lines 546-547)

    This means the "Rate not valid for this workspace" error is never displayed — the rate is silently swapped to a valid workspace rate.

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

    The validation useEffect at MoneyRequestConfirmationList.tsx:544-548 should not auto-select a matching rate when the original rate was explicitly deleted from the policy. When the transaction's customUnitRateID is not found in the workspace policy's rates AND we're in a "submit to workspace" flow (moving from self DM), the code should set the iou.error.invalidRate form error instead of auto-correcting.

    Specifically, the matching-by-value+unit block at line 544 should be skipped (or the error should still be set) when isMovingTransactionFromTrackExpense is true and the original rate ID doesn't exist in the target workspace's rates. This ensures the user sees the validation error and must manually pick a valid rate.

    What alternative solutions did you explore? (Optional)

    An alternative would be to fix this in IOURequestStepParticipants.tsx:270-283 by having addParticipant validate and flag the rate when switching to a workspace participant. However, the confirm page validation is the more appropriate place since it's the last gate before submission and already has the error display infrastructure (MoneyRequestConfirmationListFooter.tsx:453).

    Investigation details

    Key code paths:

    • Rate validation useEffect: MoneyRequestConfirmationList.tsx:527-566 — checks if rate ID is in workspace policy, auto-selects matching rate by value+unit at line 544
    • Rate resolution fallback: DistanceRequestUtils.ts:430-432 — getRate() falls back to defaultMileageRate for non-unreported expenses
    • Participant rate skip: IOURequestStepParticipants.tsx:270-283 — when isMovingTransactionFromTrackExpense && isPolicyExpenseChat, rate update is skipped, keeping the personal policy rate ID
    • Error display: MoneyRequestConfirmationListFooter.tsx:453 — shows brick road indicator when formError === 'iou.error.invalidRate'

    Data flow:

    1. User creates distance expense in self DM → gets real rate ID from personal policy (PR Feat - [Unreported] Add distance rate to the distance expenses tracked in selfDM #84136)
    2. User deletes that rate from workspace Distance rates settings
    3. User clicks "Submit it to someone" → selects workspace chat
    4. Confirm page mounts → validation useEffect fires → rate ID not in workspace policy → getRate() falls back to defaultMileageRate → matching-by-value+unit succeeds → auto-selects workspace rate → error cleared
    5. No error shown to user

    Related issue: #73680 — similar "Rate out of policy" error not shown issue (different flow)


    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.

  7. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Apr 7, 2026
  8. cristipaval commented on Apr 7, 2026

    @cristipaval
    Contributor

    Demoting this one. It's a rare use case and doesn't block the user.

  9. added
    ReviewingHas a PR in review
    and removed on Apr 8, 2026
  10. melvin-bot commented on May 1, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @cristipaval, @parasharrajat, @FitseTLT eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  11. cristipaval commented on May 4, 2026

    @cristipaval
    Contributor

    the fix is in prod

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.EngineeringMonthlyKSv2ReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions