Repository navigation
Conversation
Track distance expenses should surface the same custom unit rate violation as submit expenses on expense details, inbox previews, and Spend when a workspace rate is disabled.
Correct Policy type import in DistanceRate, fix TransactionListItem formatting, stub syncCustomUnitOutOfPolicyViolation in hook tests, and use customUnit for violation recompute typing.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54d018e913
ℹ️ 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".
…lation Leave customUnitOutOfPolicy untouched when the workspace rate cannot be resolved, add regression tests for deleted rates and FAKE_P2P_ID on policy chats, and fix comment style nits.
|
Addressed review feedback in a9b3359 |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9b3359642
ℹ️ 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".
| ]; | ||
| } | ||
|
|
||
| return hasViolation ? violations.filter((violation) => violation.name !== CONST.VIOLATIONS.CUSTOM_UNIT_OUT_OF_POLICY) : violations; |
There was a problem hiding this comment.
Preserve violations for rates owned by another workspace
When an expense belongs to workspace B but retains a rate ID owned by workspace A, the new callers resolve distanceOriginalPolicy; this branch then removes customUnitOutOfPolicy merely because that source-workspace rate is enabled. This hides the existing invalid-rate warning even though the rate is still absent from the expense report’s policy—for example, after moving an expense when the destination has no eligible replacement rate. Only clear the violation when the rate belongs to the report policy or the expense is confirmed to be a personal/self-DM expense.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks for the flag. I believe this one is out of scope here, and intentionally so.
The distanceOriginalPolicy fallback isn't new in this PR - syncCustomUnitOutOfPolicyViolation deliberately mirrors getViolationsOnyxData (ViolationsUtils.ts L660-669), which already resolves the rate from the owning workspace and clears customUnitOutOfPolicy when that rate is enabled. Keeping the render-time sync in parity is the point; if I diverged here, the violation would appear on render and then disappear on the next Onyx recompute.
The scenario you describe (moving an expense where the destination has no eligible replacement rate) is tracked as #98341, which is on HOLD for the internal workstream #100555 - its F3 item is scoped to fix exactly this in getChangeTransactionsReportOnyxData. Fixing it in this PR would mean changing the shared violations pipeline, which is beyond the scope of #93414.
garrettmknight
left a comment
There was a problem hiding this comment.
Looks good from a product perspective
|
@situchan Friendly bump, thanks!! |
|
@situchan Friendly bump, thanks! Or should we ask Melvin to take a deeper look and share the review first? |
|
@codex review |
|
@MelvinBot review |
|
🤖 Code review of 1. 🔴
|
| Self-DM distance expense, workspace rate | getViolationsOnyxData |
syncCustomUnitOutOfPolicyViolation |
|---|---|---|
Rate resolves, enabled: false |
no violation | adds violation |
| Rate unresolvable, stale violation in Onyx | removes it | keeps it |
That scenario is real, not theoretical — the pre-existing tests should resolve the distance rate from its owning policy on self DM reports and not add customUnitOutOfPolicy and should not add customUnitOutOfPolicy for self DM distance requests when the rate cannot be resolved cover exactly it.
User impact: "Rate not valid for this workspace" appears on a personal self-DM expense in Inbox and Spend, then flips when Onyx recomputes. MoneyRequestView.tsx:614-617 has the same hole: the old && !isTrackExpense guard was replaced with nothing on the new isDistanceRequest && isSelectedRateEnabled === false clause, so expense details shows it too.
Fix: pass isSelfDM into syncCustomUnitOutOfPolicyViolation and mirror L733-735, and gate the new MoneyRequestView clause on the expense being on a policy expense chat. Test step 7 only covers self-DM Track with no workspace rate, so please add the workspace-rate variant.
2. 🟡 Per-row POLICY collection subscription in Search rows
TransactionListItem/index.tsx:190 calls useDistanceRateOriginalPolicy per row, and that hook subscribes to ONYXKEYS.COLLECTION.POLICY with a selector. On a large Spend result set that's one collection subscription per row, each scanning every policy whenever any policy changes. shouldLookupDistancePolicy short-circuits the scan, but the subscription still exists. Could you sanity-check Search scroll/render on a high-traffic account with many distance rows?
3. 🟡 The issue's reported symptom is still unfixed
#93414's Expected Result is that the selected disabled rate is grayed out in the Rate list. BaseSelectListItem.tsx:54 still mutes from the interaction-stripped isDisabled, so that's unchanged. I can see from the thread that the proposal was reoriented to the violation, so this is probably intentional — just confirm whether the gray-out gets its own issue before closing.
Everything else reads well. getRate's enabled passthrough, the per-diem carve-out, the !customRate preservation from the earlier Codex round, and the pushTransactionViolationsOnyxData wiring all match the category/tag pattern. The only failing check is PR Author Checklist / checklist, which is not a real failure.
|
@situchan can you please rereview |
@MelvinBot Thanks for the flag. I believe this one is out of scope here, and intentionally so. The The scenario you describe (moving an expense where the destination has no eligible replacement rate) is tracked as #98341, which is on HOLD for the internal workstream #100555 — its F3 item is scoped to fix exactly this in cc: @situchan |
|
@situchan Bump ^ |
@situchan thoughts on this? |
|
@situchan Yes. Deleting a rate on production already shows "Rate not valid" on approved and paid expenses, and Duplicate is blocked the same way. I left that as is. Production behaviou: Screen.Recording.2026-10-07.at.6.26.07.PM.movI pushed an update so the sync only adds the disabled rate warning and no longer removes a warning the server already saved. |
|
@neerajbachani can you please explain why we don't need to add the violation to the BE here? |
|
@JS00001 The backend only saves this violation when the rate is deleted, not when it is disabled. #97838 made a disabled rate valid on purpose. Saving the warning here would flash it while editing the distance, and then the server would clear it. This PR only shows the warning on the expense, the Inbox preview, and the Spend row. Red dots, Submit, and Approve still read the saved violation, so they stay clear unless the backend starts treating a disabled rate as invalid. I can hold this PR if you want that backend change first. |
If this PR's intention is to make disabled rates invalid, then the BE should treat it that way as well, right? I'd think they should be the same |
|
@JS00001 Yeah. If a disabled rate should count as invalid everywhere, the backend should save the same violation. Right now it only does that when the rate is deleted. Happy to hold this until there's a backend change , Could you please assign a backend engineer to help us with this? |
|
PR open on the BE |
|
The BE PR is merged, will deploy at some point soon |
…14-track-distance-rate-violation # Conflicts: # src/hooks/useTransactionViolations.ts
|
@situchan can you rereview please |
|
@situchan could you take another look? I merged the latest main. The server now returns customUnitOutOfPolicy for a disabled distance rate, and UpdateMoneyRequest keeps that warning. The client was still clearing it on edit, so a disabled distance rate is now treated as out of policy. Unreported self-DM distance expenses still do not show the warning. |
|
@neerajbachani can you please retest latest changes as well? |
|
The PR description is out of date. QA step 6 may fail. |
|
yeah I retested the latest changes locally first and pushed only after it works. Disabling a distance rate shows “Rate not valid” on a reported expense, and editing the distance keeps the warning. An unreported self-DM distance expense does not show it. Screen.Recording.2026-11-03.at.2.21.42.AM.online-video-cutter.com.mp4 |
|
Updated the PR description. Thanks!! |
situchan
left a comment
There was a problem hiding this comment.
Retested both in workspace chat and self DM
|
🚧 JS00001 has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/JS00001 in version: 9.5.31-0 🚀
|
|
No help site update needed — this PR fixes missing warnings for disabled distance rates without adding a workflow or making any existing article sentence incorrect. |
|
🚀 Deployed to staging by https://github.com/JS00001 in version: 9.5.31-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.5.31-4 🚀
Bundle Size Analysis (Sentry): |
Track distance expenses should surface the same custom unit rate violation as submit expenses on expense details, inbox previews, and Spend when a workspace rate is disabled.
Explanation of Change
When a workspace distance rate is disabled, submit expenses already show a Rate not valid violation on expense details, Inbox, and Spend. Track distance expenses did not, because:
MoneyRequestViewsuppressedcustomUnitOutOfPolicyfor Track expenses.This PR mirrors the existing category/tag/tax violation path at render time:
syncCustomUnitOutOfPolicyViolationfor Inbox previews and Spend expense rows.The server stores
customUnitOutOfPolicyfor a disabled distance rate and returns it when the report is loaded and when the distance is edited. Turning the rate off does not include the violation in that response, so the render-time sync adds it until the server sends it. The sync only adds a missing warning. It never removes one the server already stored.An edit keeps the warning. A disabled distance rate is treated as out of policy, which matches the server. An unreported self-DM distance expense stays clear.
Known limitation
Re-enabling the rate does not clear a warning the server already stored. The warning stays on expense details, Inbox, and Spend until the server recomputes and drops
customUnitOutOfPolicy. Main does the same with the current backend.LHN red dots and Spend "Group by reports" badges read the stored violation, so they show once the server has saved it. The LHN red dot also needs
showInReview: true. A stored violation without that field still shows on the expense and does not light the red dot.Fixed Issues
$ #93414
PROPOSAL: #93414 (comment)
Tests
customUnitOutOfPolicy. If the response still includes it, the warning stays. This matches main.Offline tests
QA Steps
customUnitOutOfPolicy. If the response still includes it, the warning stays. This matches main.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
Screen.Recording.2026-09-10.at.3.29.39.AM.online-video-cutter.com.mp4
Android: mWeb Chrome
Record_2026-09-10-03-35-00.online-video-cutter.com.mp4
iOS: Native
Screen.Recording.2026-09-10.at.3.23.25.AM.online-video-cutter.com.mp4
iOS: mWeb Safari
Screen.Recording.2026-09-10.at.3.41.19.AM.online-video-cutter.com.mp4
MacOS: Chrome / Safari
Screen.Recording.2026-08-03.at.10.56.21.PM.online-video-cutter.com.mp4