Repository navigation
Show the auto-approval limit notice on the expense preview - #99796
Conversation
|
@arosiclair do we need a C+ to review this? |
|
@linhvovan29546 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] |
Reviewer Checklist
Screenshots/VideosMacOS: Chrome / SafariScreen.Recording.2026-09-01.at.16.39.56.mov |
|
Not sure if we consider this a bug. The RBR flashes when I add a category. Screen.Recording.2026-09-01.at.16.43.17.movEdit: the RBR flashes in the expense detail as well. It happens in both production and staging. |
We should fix that preferably. @KioCoan do you know what the root cause of that is? |
|
@linhvovan29546 I included changes to fix the flashing RBR. |
|
I think the failed check is not related to the PR and it's already tracked. |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@KioCoan what was the root problem for the flashing issue? The comments written in the PR are pretty confusing. |
Editing an expense optimistically recalculates that transaction's violations and overwrites the whole The client can only recompute the violations it knows how to calculate, so backend-only ones ( The fix just passes the stored violations in so it starts from the real list. |
|
🚧 arosiclair 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/arosiclair in version: 9.4.74-0 🚀
|
|
🤖 No help site changes are required for this PR. No draft PR created. WhyThis PR fixes a delivery gap in an existing indicator. It does not add a feature, setting, label, or workflow step, and it does not invalidate any sentence currently on the help site.
Two things worth flagging1. The QA steps point QA at the wrong page. QA step 4 says "Workspace settings > Rules > Advanced" for Auto-approve compliant reports. I drove the current web UI on a Control-plan workspace and the Rules page has no Advanced section at all — its sections are Expenses, Merchant, and Agent rules. The auto-approval settings live under Workflows > Advanced, together with Prevent self-approvals, Auto-approve reports with all expenses under, Random report audit, and Auto-pay approved reports. The That same check confirms Add-Approvals.md is correct today: "On the Workflows page, click the Auto-approve compliant reports toggle" matches the live UI. 2. A pre-existing help site inaccuracy, unrelated to this PR. Workspace-Rules.md:121-129 lists Prevent self-approvals, Auto-approve compliant reports, and Auto-Pay approved reports under "How to configure Expense Report rules" in an article whose other sections all navigate to the Rules tab. Those four settings are on Workflows > Advanced, so a reader following that article will look in the wrong place. It also renders Auto-Pay approved reports with a capital P, where the UI reads Auto-pay approved reports. I did not open a PR for this, because it is not required by these changes and sits outside the scope you asked me to review. Say the word and I will open a draft PR fixing that section. @KioCoan — there is no linked help site PR to review, because these changes need no doc updates. The two items above are the only follow-ups, and neither is caused by this PR. Reply if you want me to open the draft PR for item 2. view run · no recording available |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.4.74-2 🚀
|





Explanation of Change
Follow-up to Show the auto-approval limit notice when the submitter is also the approver, as requested in review.
That PR let a submitter who is also the report's approver see the
overAutoApprovalLimitnotice, so they finally learn why their report was held for manual approval. It landed on the expense detail Amount row and in Search, but not on the expense preview card, which is what this issue reports.The preview is the only surface that gates on the
showInReviewflag that comes down with the violation.createTransactionPreviewConditionalsaskshasNoticeTypeViolation(..., showInReview = true), which counts a notice only when the payload literally carriesshowInReview: true. The backend never sets it for this viewer: it decides that flag from whether the requester owns the report, and the violations query does not look atmanagerID, so it cannot tell that this submitter is also the approver. I confirmed the payload on a live held report, and it arrives with noshowInReviewkey at all:{"name": "overAutoApprovalLimit", "type": "notice", "data": {"amount": 10000, "currency": "USD", "formattedLimit": "$100"}}The expense detail (
useViolations) and the Search transaction row apply noshowInReviewfilter, which is why they show it today and the preview does not.Rather than change that flag in the backend, this adds a narrow exception on the client, next to the distance
MODIFIED_AMOUNTexception that already sits in the same two functions.shouldShowViolationis the single rule for who should see this notice, so the new helper asks it directly. It re-applies that rule rather than trusting the incoming array, becauseTransactionPreviewpasses violations already filtered byuseTransactionViolationswhileMoneyRequestReportTransactionListpasses raw Onyx violations, where a bare name check would light up the row for a plain submitter who must not see it.The helper is called from both
createTransactionPreviewConditionalsandtransactionHasRBR, which the file documents as mirrors of each other, so the report transaction list keeps sorting RBR rows the same way the preview flags them.The preview shows the dot and "Review required" rather than the full sentence. "Expense exceeds auto-approval limit of $100.00" is 46 characters against the 40 character
RBR_MESSAGE_MAX_CHARACTERS_FOR_PREVIEWcap, so it takes the samereviewRequiredfallback every other long violation message takes on a preview card. The full sentence still shows on the expense detail and in Search.Fixed Issues
$#99613
Tests
Unit tests
tests/unit/TransactionPreviewUtils.test.ts, two forcreateTransactionPreviewConditionalsand two fortransactionHasRBR, using anoverAutoApprovalLimitnotice with noshowInReviewkey, which is the shape the backend actually sends. Every violation fixture already in that file stampsshowInReview: true, which is why this gap was never caught.mainfirst and confirmed the two positive cases fail, so the tests prove the fix rather than the fixture.npx jest tests/unit/TransactionPreviewUtils.test.ts tests/unit/TransactionUtilsTest.ts tests/unit/useTransactionViolationsTest.ts tests/ui/TransactionPreviewContentTest.tsx tests/ui/MoneyRequestReportPreview.test.tsxand all pass. TheTransactionUtilsTestanduseTransactionViolationsTestruns guard theshouldShowViolationbehavior from PR 99016.Browser, against a local backend
Set up a workspace where I am the admin and submit to myself, with auto-approval enabled and a limit of $100, then created four reports on it: $175 held, $101 held, $150 approved and $99 auto-approved.
isProcessingReporthalf of the rule holding.Onyx.merge('report_<reportID>', {managerID: <some other accountID>})makes the dot and message disappear and flips the card button from Approve to View, and merging the real approver back restores both. That is theisReportManagerhalf of the rule holding, without needing a second account.Offline tests
N/A
QA Steps
Every expense below needs a merchant and a category, otherwise a missing field violation blocks auto-approval on its own and hides the behavior being tested.
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
Before: the $175 expense is correctly held for manual approval and the card offers an Approve button, but nothing on it says why it was not auto-approved. The approved $150 report above it is the control.

After: the same screen, same scroll position. The held report now explains itself with the dot and "Review required", and the approved report above is untouched, so the change does not leak outside reports awaiting approval.
Control, a different approver: the same held report with the approver set to someone else. No dot, no message, and the button reads View rather than Approve. This is the behavior we are deliberately preserving, since a submitter who cannot approve the report has nothing to act on.