Fix - Expense Report- "Rate not valid for this workspace" error msg not appears - #99683
Conversation
|
@mkhutornyi 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f072a74a8c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| policyCategories: policyCategories ?? {}, | ||
| hasDependentTags: policyHasDependentTags, | ||
| isInvoiceTransaction: false, | ||
| isTransactionOnPolicyExpenseChat: !isUnreported && isExpenseReport(newReport), |
There was a problem hiding this comment.
Preserve the destination context after moving the expense
When a P2P-rate distance expense is moved to a workspace while offline, this flag makes the violation appear only during the move itself; the optimistic transaction still retains its old participants. A subsequent edit or receipt change invokes getViolationsOnyxData from UpdateMoneyRequest or Receipt without this override, so the fallback reads the stale non-policy participants and removes CUSTOM_UNIT_OUT_OF_POLICY even though the expense remains on the workspace report. Persist or derive the policy-report context for every recomputation so unrelated offline edits cannot clear the new error. CLAUDE.mdL82-L87
Useful? React with 👍 / 👎.
|
@mkhutornyi still draft because I reproduced the original bug on the revert. It is a bit tricky to reproduce it happens when the network response is slow(as u can see in the vid the loading stayed long) and u need to quickly set the rate 2026-08-27.19-31-13.mp4 |
Explanation of Change
When a tracked distance expense is moved to a workspace,
changeTransactionsReportreplaced the P2P rate with the workspace default and then computed violations against the swapped transaction, soCUSTOM_UNIT_OUT_OF_POLICYwas never raised. The swap also recalculated the amount, silently changing a figure the user had entered. Both halves came from #88286, which additionally added&& customRate.enabled !== falseinViolationsUtilsand sent the substituted rate to the backend as a new API param.This reverts all four parts of #88286 so a moved expense keeps its rate and the user is told it is invalid, with two deliberate differences from a plain revert. The disabled-rate check is restored as a pending-deletion check instead, because
deletePolicyDistanceRatesleaves a rate asenabled: falsewith a pendingDELETEand seeds the violation itself — a rate that is merely disabled still calculates and must not flag. AndgetViolationsOnyxDatais now told where the transaction is landing, since a move never rewrites the transaction's ownparticipants; without that the P2P guard read the stale side of the move and cleared the violation instead of raising it optimistically.Fixed Issues
$ #96319
PROPOSAL: #96319 (comment)
Tests
Offline tests
Same as tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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.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