Repository navigation
Show an Approve anyway confirmation for report violations - #106274
Conversation
Co-authored-by: Nguyen Van Duc <dukenv0307@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
🤖 Android test steps verification results: Fixture setup remained incomplete; no approval-ready report with policy violations was obtained. The approval behavior remains unverified—not failed.
|
|
🤖 Web test steps verification results: Blocked on Web: Expenses showed “No expenses yet” and the unfiltered Reports view showed “No reports yet.” Approval behavior remains unverified because the required reports were unavailable.
|
Co-authored-by: Nguyen Van Duc <dukenv0307@users.noreply.github.com>
|
Pushed c5fa640 to fix:
Validation: 93 focused tests passed, plus lint, typecheck, spelling, and Storybook smoke tests. The full Jest run timed out locally. New CI checks are pending; the independent-approval gate still requires human review. |
|
|
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@MelvinBot In TransactionListItem, useConfirmApproveReportViolations isn't passed the transactions/violationsCollection overrides. Pls evalute |
|
The omission is real, but it does not currently cause a reachable approval-warning bug in this row.
Recommendation: Treat passing snapshot-aware overrides as defensive hardening, not a demonstrated bug fix. Add a regression test ensuring transaction rows remain View-only when their parent report is approvable. Code inspection only; no changes made or UI reproduction claimed. |
|
@MelvinBot Ah ok, but useConfirmApproveReportViolations without overrides rebuilds the whole report's violations per transaction row for an action that can never fire -> wasted work |
|
Agreed—you’re right about the wasted work. My previous response addressed correctness but missed the render cost. Each row calls the hook, which creates a fresh map and filters the report’s locally cached violations on every render ( The better fix is to remove the unused approval hook and callback wiring from the transaction row, rather than add overrides for an unreachable action. Passing No changes made; runtime impact has not been measured. |
Here are the steps: Precondition: a WS approver, 2 submitted report with at least 1 violation and 1 submitted report with no violations Steps:
Screen.Recording.2026-11-07.at.10.50.42.movScreen.Recording.2026-11-07.at.10.56.03.mov
|
Co-authored-by: Nguyen Van Duc <dukenv0307@users.noreply.github.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🤖 Web test steps verification results: ❌ fail Pushed 05fa6616 removing the unused hook, added your steps/videos, checked evidence-backed checklist items, and marked the PR ready; 19 focused tests, lint, typecheck, spelling, and Storybook passed, while full Jest timed out and compiler/formatting/translation checks remained blocked. Web testing encountered a blank page, so approval behavior and the remaining checklist items remain unverified—not demonstrated product failures.
|
|
@Julesssss 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: 05fa6616eb
ℹ️ 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".
| const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); | ||
| const hasViolations = hasViolationsReportUtils(moneyRequestReport?.reportID, transactionViolations, accountID, email ?? '', undefined, transactions); | ||
| const isAnyTransactionOnHold = hasHeldExpensesReportUtils(transactions); | ||
| const confirmApproveReportViolations = useConfirmApproveReportViolations({report: moneyRequestReport, policy, transactions, violationsCollection: transactionViolations}); |
There was a problem hiding this comment.
Filter dismissed violations before approval prompts
Pass the user-visible, filtered violation collection to the confirmation instead of the raw Onyx entries. When a violation has been dismissed through transaction.comment.dismissedViolations, getReportSubmitViolationSummary() only applies shouldShowViolation() and therefore adds the dismissed violation to the modal, even though useTransactionsAndViolationsForReport() normally removes it. This makes the report-header and Search approval buttons repeatedly warn about violations the user has already dismissed; the hold-menu and bulk-approval paths similarly pass raw collections and need the same filtering.
Useful? React with 👍 / 👎.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Co-authored-by: Nguyen Van Duc <dukenv0307@users.noreply.github.com>
|
The failing check is React Compiler Compliance, not Jest—all test jobs passed. I reproduced the cache regressions, but couldn’t fully resolve them safely: one selector still lost its cache guard after the attempted fixes. I reverted those attempts; no changes were pushed. |
|
@MelvinBot Is it related to this PR? |
|
Yes—it’s related to this PR, not an unrelated/flaky test. The compiler check confirms that computations cached on |
|
@MelvinBot New inline computes (warningData = getReportApprovalWarningData(...), and the [...new Set(...)] transaction-ID union) feed hook calls mid-render. React Compiler memo scopes can't span a hook, so it dropped caching on those + upstream computes (getNonEmptyStringOnyxID, isInvoiceReport). Solution: Moved the computations into their own hooks (useReportApprovalWarningData, useLiveViolationsForSnapshotTransactions) so call sites chain hook results instead. Behavior unchanged; compliance check + lint + affected tests pass. Pls evaluate and fix |
Co-authored-by: Nguyen Van Duc <dukenv0307@users.noreply.github.com>
|
@Julesssss All yours! |
| } | ||
| approvalTransactions.push(transaction); | ||
| // Raw overrides must respect the approver's dismissals before warnings are classified or deduplicated. | ||
| approvalViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`] = getTransactionViolations( |
There was a problem hiding this comment.
This only drops dismissed violations, so overAutoApprovalLimit still shows for a non-submitter admin on a processing report. That notice is why the report needs manual approval, so every report held for being over the auto-approval limit will hit "Approve anyway?". Could we exclude it by name here? Filtering on showInReview won't work as Auth sets it to true for approvers. Please add a notice case to getReportSubmitViolationSummaryTest too
There was a problem hiding this comment.
@Julesssss, should we just filter out overAutoApprovalLimit only? Its type is notice, so i guess we may filter out all notice violations?
There was a problem hiding this comment.
should we just filter out overAutoApprovalLimit only?
Yeah I think just that one. overAutoApprovalLimit is the only one that explains why the report is waiting for approval rather than flagging an expense
| if (skipAnimation) { | ||
| return; | ||
| } | ||
| confirmApproveReportViolations(() => { |
There was a problem hiding this comment.
Could you add a test for cancel and confirm here? This path wraps the animation, approveMoneyRequest, clearSelectedTransactions and onCleanup in one callback. The only consumer test mocks this hook, so a cancel that still clears the selection or approves wouldn't be caught. The it.each([CLOSE, CONFIRM]) pattern in useConfirmApproval.test.ts should work
There was a problem hiding this comment.
Addressed in 41546bfc. Added direct lifecycle-hook CLOSE/CONFIRM tests for both animation modes using the real approval confirmation logic. They assert approval, animations, selection clearing, and cleanup stay blocked before confirmation and after cancellation, and verify the approval completion callback. All four cases pass.
| isTrackIntentUser, | ||
| allTransactionViolations: transactionViolations, | ||
| }); | ||
| confirmApproveReportViolations(() => { |
There was a problem hiding this comment.
Same here, this is the other path that can approve held expenses with violations and it has no confirm/cancel coverage. Could we add one, including full=false leaving out the held expenses?
There was a problem hiding this comment.
Addressed in 41546bfc. Added real-confirmation hook tests for CLOSE/CONFIRM with full and partial approval, including completion callback forwarding. Two additional cases verify held-only warnings are excluded for partial approval but still warn for full approval. All six cases pass; hold-menu dismissal behavior is unchanged.
| /** Confirms any unacknowledged report violations before proceeding with the SUBMIT action. */ | ||
| confirmSubmitReportViolations: (onProceed: ConfirmSubmitReportViolationsOnProceed) => void; | ||
| /** Confirms report violations before the APPROVE action proceeds; approval is skipped if omitted. */ | ||
| confirmApproveReportViolations?: (onProceed: () => void) => void; |
There was a problem hiding this comment.
NAB: Lets make this required like confirmSubmitReportViolations. Right now APPROVE silently does nothing if a caller leaves it out, and a required param would make that a compile error instead
There was a problem hiding this comment.
Addressed in 41546bfc. The callback is required and invoked without optional chaining. Updated the remaining callers; transaction rows explicitly never proceed because they cannot offer approval, preserving the removal of unnecessary per-row hook work. Typecheck and Search action tests pass.
|
@MelvinBot Merge main, then fix #106274 (comment), #106274 (comment) and #106274 (comment) |
Co-authored-by: Nguyen Van Duc <dukenv0307@users.noreply.github.com>
|
🤖 Web test steps verification results: ❌ fail Merged main and addressed all three comments in 41546bfc: added confirmation/cancellation coverage and made the Search callback required; 163 focused tests, lint, typecheck, formatting, spelling, and Storybook passed. Web verification was blocked by a blank page; full Jest timed out, and compiler-wrapper/translation checks remained blocked.
view run · no recording available |
This comment has been minimized.
This comment has been minimized.
|
@MelvinBot Resolve conflict and fix #106274 (comment) |
…ings Co-authored-by: Nguyen Van Duc <dukenv0307@users.noreply.github.com>
🦜 Polyglot Parrot! 🦜Squawk! Looks like you added some shiny new English strings. Allow me to parrot them back to you in other tongues: View the translation diffdiff --git a/src/languages/es.ts b/src/languages/es.ts
index 08e16961..32d4ecb3 100644
--- a/src/languages/es.ts
+++ b/src/languages/es.ts
@@ -1537,10 +1537,7 @@ const translations: TranslationDeepObject<typeof en> = {
pendingMatchWithCreditCard: 'Recibo pendiente de adjuntar con la transacción de la tarjeta',
pendingMatchWithCreditCardDescription: 'Recibo pendiente de adjuntar con la transacción de la tarjeta. Márcalo como efectivo para cancelar.',
markAsCash: 'Marcar como efectivo',
- confirmApproveReportViolations: {
- title: '¿Aprobar de todas formas?',
- description: 'Este informe tiene infracciones de la política. ¿Seguro que quieres aprobarlo sin hacer cambios?',
- },
+ confirmApproveReportViolations: {title: '¿Aprobar de todos modos?', description: 'Este informe tiene infracciones de la política. ¿Seguro que quieres aprobarlo sin hacer cambios?'},
confirmSubmitReportViolations: {
title: '¿Enviar informe?',
description: 'Este informe tiene infracciones de política. ¿Seguro que quieres enviarlo sin hacer cambios?',
diff --git a/src/languages/fr.ts b/src/languages/fr.ts
index 5b34aa46..9e48d578 100644
--- a/src/languages/fr.ts
+++ b/src/languages/fr.ts
@@ -1572,8 +1572,8 @@ const translations: TranslationDeepObject<typeof en> = {
pendingMatchWithCreditCardDescription: 'Reçu en attente de rapprochement avec une transaction par carte. Marquez comme paiement en espèces pour annuler.',
markAsCash: 'Marquer comme espèces',
confirmApproveReportViolations: {
- title: 'Approuver quand même ?',
- description: 'Cette note de frais comporte des violations de politique. Voulez-vous vraiment l’approuver sans y apporter de modifications ?',
+ title: 'Approuver quand même ?',
+ description: 'Cette note de frais comporte des violations de la politique. Voulez-vous vraiment l’approuver sans y apporter de modifications ?',
},
confirmSubmitReportViolations: {
title: 'Soumettre le rapport ?',
diff --git a/src/languages/it.ts b/src/languages/it.ts
index d08723bb..78ce3ed7 100644
--- a/src/languages/it.ts
+++ b/src/languages/it.ts
@@ -1564,7 +1564,7 @@ const translations: TranslationDeepObject<typeof en> = {
markAsCash: 'Segna come contante',
confirmApproveReportViolations: {
title: 'Approvi comunque?',
- description: 'Questo report presenta violazioni della policy. Vuoi davvero approvarlo senza apportare modifiche?',
+ description: 'Questo resoconto presenta violazioni della policy. Sei sicuro di volerlo approvare senza apportare modifiche?',
},
confirmSubmitReportViolations: {
title: 'Invia il rapporto?',
diff --git a/src/languages/ja.ts b/src/languages/ja.ts
index af2d57af..08fe8612 100644
--- a/src/languages/ja.ts
+++ b/src/languages/ja.ts
@@ -1545,10 +1545,7 @@ const translations: TranslationDeepObject<typeof en> = {
pendingMatch: '保留中の照合',
pendingMatchWithCreditCardDescription: 'レシートはカード取引との照合待ちです。現金としてマークしてキャンセルします。',
markAsCash: '現金としてマーク',
- confirmApproveReportViolations: {
- title: 'それでも承認しますか?',
- description: 'このレポートにはポリシー違反があります。変更を行わずに承認してもよろしいですか?',
- },
+ confirmApproveReportViolations: {title: 'このまま承認しますか?', description: 'このレポートにはポリシー違反があります。変更を加えずに承認してもよろしいですか?'},
confirmSubmitReportViolations: {
title: 'レポートを送信しますか?',
description: 'このレポートにはポリシー違反があります。変更を加えずに送信してもよろしいですか?',
diff --git a/src/languages/nl.ts b/src/languages/nl.ts
index f3dcf905..20aef576 100644
--- a/src/languages/nl.ts
+++ b/src/languages/nl.ts
@@ -1562,7 +1562,7 @@ const translations: TranslationDeepObject<typeof en> = {
markAsCash: 'Markeren als contant',
confirmApproveReportViolations: {
title: 'Toch goedkeuren?',
- description: 'Dit rapport bevat beleidsinbreuken. Weet je zeker dat je het wilt goedkeuren zonder wijzigingen aan te brengen?',
+ description: 'Dit rapport bevat beleidschendingen. Weet je zeker dat je het wilt goedkeuren zonder wijzigingen aan te brengen?',
},
confirmSubmitReportViolations: {
title: 'Rapport verzenden?',
diff --git a/src/languages/pl.ts b/src/languages/pl.ts
index c373bf01..08f5243f 100644
--- a/src/languages/pl.ts
+++ b/src/languages/pl.ts
@@ -1600,10 +1600,7 @@ const translations: TranslationDeepObject<typeof en> = {
pendingMatch: 'Oczekujące dopasowanie',
pendingMatchWithCreditCardDescription: 'Oczekuje na dopasowanie paragonu do transakcji kartą. Oznacz jako gotówkę, aby anulować.',
markAsCash: 'Oznacz jako gotówkę',
- confirmApproveReportViolations: {
- title: 'Zatwierdzić mimo to?',
- description: 'Ten raport zawiera naruszenia zasad. Na pewno chcesz go zatwierdzić bez wprowadzania zmian?',
- },
+ confirmApproveReportViolations: {title: 'Zatwierdzić mimo to?', description: 'Ten raport zawiera naruszenia zasad. Na pewno chcesz go zatwierdzić bez wprowadzania zmian?'},
confirmSubmitReportViolations: {
title: 'Wysłać raport?',
description: 'Ten raport zawiera naruszenia zasad. Czy na pewno chcesz go wysłać bez wprowadzania zmian?',
diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts
index aaf3e0a3..f6cf6b76 100644
--- a/src/languages/pt-BR.ts
+++ b/src/languages/pt-BR.ts
@@ -1562,10 +1562,7 @@ const translations: TranslationDeepObject<typeof en> = {
pendingMatch: 'Correspondência pendente',
pendingMatchWithCreditCardDescription: 'Recibo aguardando correspondência com transação do cartão. Marque como dinheiro para cancelar.',
markAsCash: 'Marcar como dinheiro',
- confirmApproveReportViolations: {
- title: 'Aprovar mesmo assim?',
- description: 'Este relatório tem violações da política. Tem certeza de que quer aprová‑lo sem fazer alterações?',
- },
+ confirmApproveReportViolations: {title: 'Aprovar mesmo assim?', description: 'Este relatório tem violações da política. Tem certeza de que quer aprová-lo sem fazer alterações?'},
confirmSubmitReportViolations: {
title: 'Enviar relatório?',
description: 'Este relatório tem violações de política. Tem certeza de que deseja enviá-lo sem fazer alterações?',
diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts
index f1835341..1b53a1c0 100644
--- a/src/languages/zh-hans.ts
+++ b/src/languages/zh-hans.ts
@@ -1498,10 +1498,7 @@ const translations: TranslationDeepObject<typeof en> = {
pendingMatch: '待匹配',
pendingMatchWithCreditCardDescription: '收据正在等待与卡片交易匹配。将其标记为现金以取消。',
markAsCash: '标记为现金',
- confirmApproveReportViolations: {
- title: '仍然批准?',
- description: '此报表存在策略违规。确定要在不进行任何更改的情况下批准吗?',
- },
+ confirmApproveReportViolations: {title: '仍然批准?', description: '此报表存在策略违规。确定要在不做任何更改的情况下批准吗?'},
confirmSubmitReportViolations: {
title: '提交报告?',
description: '此报告存在违反政策的情况。您确定要不做任何更改就提交吗?',
Note You can apply these changes to your branch by copying the patch to your clipboard, then running |
|
🤖 Web test steps verification results: ❌ fail Pushed 1cbbcaab: resolved the merge conflict and excluded only
view run · no recording available |
garrettmknight
left a comment
There was a problem hiding this comment.
Looks good from a product perspective.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 Julesssss has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.5.43-0 🚀
|
|
No help site update needed — this PR adds a self-explanatory approval confirmation for reports with violations without changing approval rules or making existing article instructions incorrect. |
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.5.47-0 🚀
|
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.5.51-0 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.5.51-1 🚀
Bundle Size Analysis (Sentry): |





Explanation of Change
Approvers can currently approve reports without noticing their policy violations. Reuse the submit warning's modal and violation bullets to ask Approve anyway? before approval proceeds.
AI Tests
Latest conflict resolution and approval-notice fix (2026-11-18):
overAutoApprovalLimitfrom approval warnings. Added three regression cases for a non-submitter admin on a processing report, full/partial approval, preservation of other notices, unchanged submission warnings, and source-data immutability.origin/); translation dry-run failed during ts-node initialization with an undefined TypeScript fileExists API.Latest main merge and review coverage (2026-11-17):
Latest compiler-cache fix (2026-11-13):
Latest Search snapshot fix and main merge (2026-11-13):
Latest test-fixture and translation update (2026-11-12):
Latest main-merge validation (2026-11-12):
Latest dismissed-violation fix validation (2026-11-07):
Latest formatting-fix validation (2026-11-07):
Latest review follow-up validation (2026-11-07):
Latest CI-fix validation (2026-11-07):
prettiernpm script is absent. Direct Oxfmt invocation was blocked by runner permissions, so formatting validation is left to CI.Original implementation validation:
@react-navigation/coreas an ES module.Contributor branch access
This PR uses an upstream branch because Melvin cannot push to the contributor's fork. To copy the branch into your fork:
You can then open a replacement PR from your fork and close this draft.
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/696578
Tests
Manual test plan supplied by
dukenv0307. These are expected outcomes, not a claim that Melvin completed them; the latest Web attempt was blocked by a blank application page.Precondition: signed in as a workspace approver, with two submitted reports containing at least one violation each and one submitted report without violations. Restore or add reports as needed before the preview and bulk cases.
Offline tests
Not verified. Load a submitted violation report while online, disconnect, then click Approve. Verify cached violations appear in the confirmation; Cancel must leave the report unapproved. Confirm approval and reconnect to verify synchronization without duplicate approval.
QA Steps
Same as Tests, using QA-owned submitted reports on staging. Verify the rendered title against approved product copy. Also cover held expenses/full versus partial approval and the offline test above. These QA outcomes remain unverified by Melvin.
PR Author Checklist
Checkboxes below were marked on
dukenv0307's behalf at their request, not as test attestations. Cross-platform, offline, accessibility, console, and manual approval-flow verification remains unverified by Melvin; see AI Tests for the checks actually executed. The attached videos are requester-provided and were not independently reviewed.### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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
Latest Web attempt (2026-11-18): no app session was available, blocking approval verification.
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Videos supplied by
dukenv0307(not independently reviewed by Melvin):Screen.Recording.2026-11-07.at.10.50.42.mov
Screen.Recording.2026-11-07.at.10.56.03.mov
Latest automated Web attempt: blank application page blocked approval verification.
Latest dismissed-violation verification attempt: blank Web session prevented access to report-header, Search/bulk, held-expense, and submitter-dismissal test cases.
Post-merge Web verification (2026-11-12): the blank session prevented access to the approval test fixtures.
Latest test-fixture/translation Web attempt: a blank page prevented manual approval verification.
Post-merge Web verification (2026-11-17): app readiness blocked all eight approval assertions.