Skip to content

Fix: distance Rate list empty after self-DM → workspace when submissions off - #98592

Draft
MelvinBot wants to merge 2 commits into
mainfrom
claude-distanceRateEmptySelfDMWorkspace
Draft

Fix: distance Rate list empty after self-DM → workspace when submissions off#98592
MelvinBot wants to merge 2 commits into
mainfrom
claude-distanceRateEmptySelfDMWorkspace

Conversation

@MelvinBot

Copy link
Copy Markdown
Contributor

Explanation of Change

When a workspace has submissions (delayed submission) disabled, the new manual-expense flow seeds a Track distance expense onto the self-DM, whose report carries the placeholder _FAKE_ policy. Selecting a workspace chat via the in-place "To" picker updates the transaction participants, but the confirmation route still points at the self-DM.

The confirmation page already works around this (#96576) by resolving the policy from the selected participant (selectedWorkspacePolicyID), which is why the Rate menu item there shows the correct rate. The Rate page never got that workaround — it passed the self-DM's report?.policyID (_FAKE_/undefined) straight into usePolicyForTransaction, so getMileageRates() ran against an undefined policy and the rate list rendered empty.

This change makes IOURequestStepDistanceRate resolve its policy from the selected workspace participant (mirroring selectedWorkspacePolicyID on the confirmation page), falling back to the route report?.policyID when there's no participant policy — so the workspace's distance rates load. The fallback keeps every other flow (editing, split, P2P) unchanged.

🤖 Melvin automated checks

Ran locally on the changed file: ESLint (lint-changed), typecheck-tsgo, react-compiler-compliance-check, and the distance-rate unit suites (DistanceRateTest, useDistanceRateOriginalPolicyTest, DistanceRequestUtilsTest) — all passed.

Live web verification of the repro flow could not be completed: the test session's page rendered blank (an environment issue unrelated to this change — the same environment issue noted during the original investigation). The human co-author should complete the manual Tests/QA steps below.

Fixed Issues

$ #98323
PROPOSAL: #98323 (comment)

Tests

  1. Use a workspace (Collect/Control) with Distance rates enabled and Delayed submission turned OFF (submissions disabled).
  2. From the FAB, choose Track distance > Manual.
  3. Enter a distance amount, then tap Next.
  4. On the confirmation page, tap the To field and select the submissions-disabled workspace chat.
  5. Back on the confirmation page, tap the Rate field.
  6. Verify the Rate list shows the workspace's distance rate(s) and is not empty.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests.

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

…ipant

Co-authored-by: Eugene Voloshchak <eVoloshchak@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team August 13, 2026 13:46
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I created this PR from an upstream branch since I don't have push access to your fork.

To take ownership of this branch and be able to push updates, run:

git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-distanceRateEmptySelfDMWorkspace
git checkout -b claude-distanceRateEmptySelfDMWorkspace upstream/claude-distanceRateEmptySelfDMWorkspace
git push -u origin claude-distanceRateEmptySelfDMWorkspace

Then you can close this PR and open a new one from your fork.

Co-authored-by: Eugene Voloshchak <eVoloshchak@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Fixed the failing Oxfmt check.

The selectedWorkspacePolicyID assignment was split across two lines; oxfmt wanted it on one. Ran npm run fmt and pushed the result (e472f80).

The other two failing checks are non-blocking and not related to the code:

  • Check independent approval — awaits review
  • PR Author Checklist / checklist — awaits the author checklist being completed

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No failing checks right now. The Oxfmt failure was already fixed in e472f80 (ran npm run fmt on IOURequestStepDistanceRate.tsx), and a fresh CI run is now validating it — all checks are currently pending, none failing.

If any check fails once this run settles, re-tag me and I'll dig in.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No code fix needed — the earlier Oxfmt failure is resolved and now passing.

The only two remaining failing checks are non-blocking and not tied to the code:

  • Check independent approval — awaits review
  • PR Author Checklist / checklist — awaits the author checklist being completed

All other checks are passing or currently re-running.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ Something went wrong. This may be a transient issue — try again. If it persists, check status.anthropic.com.

Run details

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The Oxfmt check I fixed earlier now passes. The remaining failing checks are all unrelated to this PR (which only touches IOURequestStepDistanceRate.tsx), so I'm not pushing a change for them.

test (job 1) — pre-existing, unrelated. tests/unit/SignInBackButtonTest.tsx fails with TypeError: _Navigation.default.dismissModal is not a function. Its Navigation mock only stubs goBack, but SignInModal.tsx:60 calls Navigation.dismissModal(), which the mock doesn't provide. This is entirely within the sign-in test and its incomplete mock — nothing to do with the distance-rate change here.

baseline-perf-tests — infra flake. Failed at Upload baseline performance results with Failed to CreateArtifact: Unable to make request: ETIMEDOUT — a GitHub artifact-upload network timeout, not a code failure. A re-run should clear it.

Check independent approval / checklist — these await review/author-checklist completion and aren't code issues.

Evidence
  • PR changes exactly one file: src/pages/iou/request/step/IOURequestStepDistanceRate.tsx.
  • The mock in SignInBackButtonTest.tsx defines default: { goBack } with no dismissModal.
  • dismissModal is a real export of Navigation.ts, so this is purely a test-mock gap, not a runtime regression.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The two remaining failing checks are not related to this PR — no fix to push.

test (job 1) — fails on tests/unit/SignInBackButtonTest.tsx with TypeError: _Navigation.default.dismissModal is not a function. This PR only changes IOURequestStepDistanceRate.tsx — all distance-rate suites (DistanceRateTest, useDistanceRateOriginalPolicyTest) passed. The failing test's Navigation mock only stubs goBack, not dismissModal, so it throws when SignInModal's post-sign-in effect fires. Both the test and SignInModal.tsx are byte-identical to main, and the dismissModal() call sits behind an Onyx-state-gated useEffect (SignInModal.tsx:60) — i.e. a pre-existing flaky test independent of this change.

baseline-perf-tests — failed at Upload baseline performance results with Failed to CreateArtifact: Unable to make request: ETIMEDOUT. That's a CI artifact-upload infra timeout, not a code failure.

The other two red checks (Check independent approval, PR Author Checklist / checklist) are non-blocking and just await review / the author checklist.

A re-run should clear both test (job 1) and baseline-perf-tests.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants