Preserve distance rate for unreported expenses from non-default policies#87537
Preserve distance rate for unreported expenses from non-default policies#87537
Conversation
When a distance request is unreported from a report tied to a non-default policy, resolve the policy that owns the customUnitRateID and use it instead of the default moving-expenses policy. This mirrors the existing pattern for perDiem requests. Co-authored-by: Cristi Paval <cristipaval@users.noreply.github.com>
|
The failing check is unrelated to this PR. Failing test: Analysis: This PR only modifies Evidence: This appears to be a pre-existing/flaky test failure. The PR's changes have no connection to profile page contact methods or brick road indicators. |
|
@MelvinBot, could you please merge the latest main into this one?= Also, we need to pass the policyID to the backend when updating the distance. |
…ceRateOnUnreport Co-authored-by: Cristi Paval <cristipaval@users.noreply.github.com>
Add policyID to UpdateMoneyRequestParams and include it in API params for both getUpdateMoneyRequestParams and getUpdateTrackExpenseParams so the backend receives the correct policy context when updating distance. Co-authored-by: cristipaval <cristipaval@users.noreply.github.com> Co-authored-by: Cristi Paval <cristipaval@users.noreply.github.com>
|
Done! I've:
|
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
HOLD removed, @FitseTLT. This can be tested in staging |
|
Ok |
trjExpensify
left a comment
There was a problem hiding this comment.
Unreported expense project PR 👍
|
|
|
bump @FitseTLT |
|
@MelvinBot assign me |
|
📋 Done! @FitseTLT has been added as an assignee to this PR. |
|
@MelvinBot BUG: |
|
👋 Root cause: The By resolving To fix: These two concerns need to be decoupled — the rate display should use the original policy (to show the correct rate name/value), but the rate picker should use |
|
Yep make sense @MelvinBot |
|
@MelvinBot, @FitseTLT agreed with your suggested fix for the bug. Could you please implement it? |
|
@MelvinBot, I see your process was canceled. Could you try again? |
The rate picker was showing rates from the original non-default workspace instead of the user's default workspace for unreported distance expenses. This decouples the rate display (which correctly uses the original policy) from the rate picker list (which now uses policyForMovingExpenses). Co-authored-by: Cristi Paval <cristipaval@users.noreply.github.com>
f7da923
|
@cristipaval Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Fixed! The rate picker now uses Change: Checks: prettier, eslint, typecheck, and 152 unit tests all pass. |
|
@FitseTLT, could you please test again? 🙏 |
|
@cristipaval This pr is making a lot of changes. Like tag, categories etc pages all are using the non-default workspace. I don't think this is a correct behavior. If I understood it correctly the fix is just passing this correct non-default workspace policyID param to the BE when updating distance, right? If it is correct then why don't we make the changes in this scope. 😕 |
Held on https://github.com/Expensify/Web-Expensify/pull/52149Explanation of Change
When a distance request is unreported from a report tied to a non-default policy, the distance rate was being lost because the unreported expense was associated with the user's default policy (
policyForMovingExpenses), which doesn't contain the originalcustomUnitRateID.This PR applies the same pattern already used for perDiem requests: resolve the policy that owns the
customUnitRateIDand use it instead of the default policy. Specifically:PolicyUtils.ts: AddedgetPolicyByCustomUnitRateID()— searches all policies for one whose distance custom unit contains the transaction'scustomUnitRateID(mirrorsgetPolicyByCustomUnitIDfor perDiem).MoneyRequestView.tsx: For unreported distance requests, resolve the policy via the new function so the correct rate and policy are passed to the backend.usePolicyForTransaction.ts: Extended the self-DM expense policy resolution to also handle distance requests by looking up the policy that owns thecustomUnitRateID.Fixed Issues
$ #87204
PROPOSAL: #87204 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-04-16.at.20.20.49.mov
Checks run:
prettier— pass (no formatting changes)eslint— pass (pre-existing warning in PolicyUtils.ts line 76 unrelated to this PR)typecheck— passjest(PolicyUtils, MoneyRequestView tests) — pass (151 tests)Co-authored-by: cristipaval cristipaval@users.noreply.github.com