[$175] [Exploratory] Distance - Can't select the rate after change the report to another Workspace
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: v9.5.25-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/81167638/folder/57605203/46440229/1923342598?sort=%2Bidentifier Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Windows 11/Chrome App Component: Chat Report View
Action Performed:
Preconditions The user has at least two workspaces: Workspace 1: An existing workspace. Workspace 2: A new workspace with no prior expenses. Both workspaces have "Delayed Submissions" and "Approvals" enabled. Steps:
- Log in as the workspace admin
- Navigate to the chat for "Workspace 1"
- Create a Distance expense
- On the expense preview, Click on the "Submit" button
- Navigate to the "Workspaces"
- Click on the "More"
- Click on the "Delete" (or Archive if use Expensifail account)
- Navigate to the deleted Workspace chat
- Open the expense report that was just created
- Click on the "More" and select "Change Workspace" - Select Workspace 2
- Go back and open the Reports with distance expense
- Click on the Rate - Select the valid rate
Expected Result:
The error "rate not valid for this workspace" disappears
Actual Result:
Error "rate not valid for this workspace" reappears again
Workaround:
Unknown
Platforms:
- [x] Android: App
- [ ] Android: mWeb Chrome
- [x] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/a00e3cb8-5bd4-4d05-b9c2-f05a8bc95e55
Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7299365
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022117414620161059446
- Upwork Job ID: 2117414620161059446
- Last Price Increase: 2026-11-03
Issue Owner
Current Issue Owner: @nkdengineer
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/e2182d34ae5a07744d71cd63569f0fead8600985d3e02f8e03ac904e974069b5
Issue Analysis
Root Cause: This appears to be a backend/internal issue. A separate internal investigation is needed.
I reproduced the bug on web. The App removes the "Rate not valid for this workspace" violation when you pick a Workspace 2 rate, but it stays on screen. The violation most likely comes back from the server, not the App.
Recommended Fix: The fix needs changes outside the App repo. Please escalate to an internal engineer. Planned App work in [HOLD Expensify 679405] Add optimistic distance rate updates when a report's workspace changes would likely prevent this state. That work auto-selects a valid rate during Change workspace, so you would not need to pick one.
Investigation details
Repro (web, dev build): I followed the issue steps with two new workspaces, a submitted 10 mi distance expense, deleting Workspace A, then Change workspace to Workspace B.
- After Change workspace, the expense shows "Rate out of policy / Rate not valid for this workspace".
- I picked "Default Rate, $0.76 / mile" and saved. Reopening the picker shows that rate selected, so the save worked. The error was still there after about 13 seconds.
Why the App is not the source:
- The rate picker lists rates and saves with the same policy, taken from the transaction thread's
policyID: DynamicIOURequestStepDistanceRate.tsx:91-142 and L245-L270. - Optimistic violations use that policy (UpdateMoneyRequest.ts:2400).
customUnitOutOfPolicyis removed when the policy contains the new rate (ViolationsUtils.ts:853-873).
Likely contributing state:
changeReportPolicyonly updates thepolicyIDof the report and its threads (Report/index.ts:8367). It leaves the transaction'scomment.customUniton the old workspace.- A rate change updates only
customUnitRateID(getUpdatedTransaction.ts:282-284). The transaction keeps Workspace A'scustomUnitIDwith a Workspace B rate ID. If the server checks the rate against stale data, it adds the violation back.
Not verified: I could not check server logs in this run. To confirm, check whether the UpdateMoneyRequestDistanceRate response adds customUnitOutOfPolicy back to the transaction's violations. One App-side case is still possible: the thread's policyID might not have moved to Workspace B. The logs would show this, because the request would then send a Workspace A rate ID.
Related issues:
Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.
view run · no recording available
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ChavdaSachin (External)
Job added to Upwork: https://www.upwork.com/jobs/~022117414620161059446
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abzokhattab (External)
@abzokhattab plz take over as C+
Sure ... taking a-look in the morning
This is caused by changeReportPolicy not updating the transaction's comment.customUnit fields (customUnitID / customUnitRateID) when moving to a new workspace. After "Change Workspace", the transaction still carries the old workspace's customUnitID. When the user then picks a valid rate from the new workspace, only customUnitRateID updates .. the server sees the customUnitID mismatch and re-adds the customUnitOutOfPolicy violation.
This is the exact scenario that #100559 (F4 in the tracking issue #100555) is designed to fix ,, it will make changeReportPolicy auto-select a valid rate and update all custom unit fields during the workspace change itself. That work is on HOLD pending backend changes in Expensify#679405.
Putting this on HOLD for #100559.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a distance expense report is created in Workspace 1, Workspace 1 is deleted, and the expense report is moved to Workspace 2 via More > Change Workspace, opening the distance expense's Rate page and selecting a valid distance rate from Workspace 2 fails to clear the "Rate not valid for this workspace" (customUnitOutOfPolicy) violation — the error reappears shortly after saving.
What is the root cause of that problem?
There are two connected client-side issues in the distance rate update flow after a report's workspace is changed:
getUpdatedTransactionupdatescustomUnitRateIDwithout updatingcustomUnitIDto the new workspace's distance custom unit (src/libs/TransactionUtils/getUpdatedTransaction.ts, lines 282–292): When the distance expense was originally created in Workspace 1,transaction.comment.customUnitstored Workspace 1'scustomUnitIDandcustomUnitRateID. When the report is moved to Workspace 2 viachangeReportPolicy,transaction.comment.customUnit.customUnitIDstill holds Workspace 1'scustomUnitID. When the user then opens the Rate picker and selects a valid rate from Workspace 2,setMoneyRequestDistanceRate->updateMoneyRequestDistanceRate(src/libs/actions/IOU/UpdateMoneyRequest.ts) callsgetUpdatedTransaction:
Proposal
Please re-state the problem that we are trying to solve in this issue.
After deleting the original workspace (Workspace 1) and moving a submitted distance expense report to another workspace (Workspace 2), the distance expense displays a Rate not valid for this workspace (customUnitOutOfPolicy) violation. When the user opens the Rate selector and chooses the valid rate from Workspace 2, the violation remains and the new rate cannot be saved.
What is the root cause of that problem?
There are two interacting issues across changeReportPolicy and updateMoneyRequestDistanceRate:
- In
src/libs/actions/Report/index.ts(changeReportPolicy/changeReportPolicyAndInviteSubmitter), when an expense report is moved to a new workspace (policy), the optimistic Onyx updates do not migrate distance transactions'comment.customUnit.customUnitRateIDto the destination workspace's default P2P/distance rate, leaving the deleted workspace's stalecustomUnitRateIDon the transaction along with thecustomUnitOutOfPolicyviolation. - When the user subsequently selects a valid rate from
Workspace 2on the moved report,updateMoneyRequestDistanceRateinsrc/libs/actions/IOU/UpdateMoneyRequest.ts(lines 2220–2335) callsgetUpdateMoneyRequestParams(UpdateMoneyRequest.ts:1166), which dispatchesAPI.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DISTANCE_RATE, ...). However, insrc/pages/iou/request/step/IOURequestStepDistanceRate.tsx(lines 118–155),policyis resolved viausePolicy(report?.policyID). When the transaction was inspected from a transaction thread report (report),report.policyIDon the child transaction thread report can still reference the old deleted workspace ID ifchangeReportPolicyonly updated the parentiouReport.policyIDand not the child transaction thread report'spolicyIDin Onyx. As a result,IOURequestStepDistanceRateeither looks up rates on the wrong policy or passespolicywith a mismatchedpolicyIDtoupdateMoneyRequestDistanceRate, and the backend rejects or returns thecustomUnitOutOfPolicyviolation.
What changes do you think we should make in order to solve the problem?
- In
src/pages/iou/request/step/IOURequestStepDistanceRate.tsx, resolve the effectivepolicyIDfromparentReport?.policyID ?? report?.policyID(whereparentReportisONYXKEYS.COLLECTION.REPORTfortransaction?.reportID) so that moving the parent expense report toWorkspace 2always usesWorkspace 2's policy and distance rates even if the transaction thread report still carries the oldpolicyID. - In
src/libs/actions/Report/index.ts(buildOptimisticMovedReportData/changeReportPolicy), also update any existing child transaction thread reports'policyIDinoptimisticDatatonewPolicy.id, and when moving distance transactions whosecustomUnitRateIDdoes not exist onnewPolicy, clear or remapcustomUnitOutOfPolicyconsistently once a valid rate onnewPolicyis selected.
What alternative solutions did you explore? (Optional)
We also considered automatically remapping the distance rate inside changeReportPolicy on the client, which helps when moving to a workspace with a default rate, but resolving parentReport?.policyID in IOURequestStepDistanceRate.tsx and syncing child transaction thread policyIDs ensures manual rate selection always targets the moved report's current workspace.
📣 @jeff-graham-ai! 📣 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:
- Make sure you've read and understood the contributing guidelines.
- 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.
- 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.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
I don't have the capacity to follow up on this. reassigning
Triggered auto assignment to Contributor-plus team member for initial proposal review - @nkdengineer (External)
Feel free to take over this issue @nkdengineer
@nkdengineer this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
@nkdengineer Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Can't reproduce anymore.
@nkdengineer Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@nkdengineer Still overdue 6 days?! Let's take care of this!
Not overdue. Waiting for reset.