You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-09-16] [$250] Submit button remains enabled for violating reports and shows generic error when strict workflow rules are enforced #92367
Version Number: Reproducible in staging?: Needs reproduction (Unable to reproduce) Reproducible in production?: Needs reproduction If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by:@clarajones-expensify Slack conversation (hyperlinked to channel name): #Expensify Bugs
Action Performed:
Configure a domain with Strictly Enforce Workflow Rules enabled.
Create or open a report containing one or more policy violations that block submission.
Open the report preview.
Click Submit.
Expected Result:
The Submit button should be disabled when the report contains blocking violations and submission is restricted by the domain setting.
The UI should clearly display the specific violation(s) preventing submission.
Actual Result:
The Submit button remains enabled.
Clicking Submit results in a generic error message:
"Unexpected error. Please try again."
The actual violation details are not displayed to the user.
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
The report preview Submit button ignores the "Strictly Enforce Workspace Rules" domain setting, so it stays enabled for reports with policy violations. Clicking it fires submitReport() anyway, the backend rejects it, and the user gets the generic Unexpected error. Please try again. (en.ts:1512). The report header Submit button already handles this correctly — which is likely why this is hard to reproduce (depends on which Submit button you click).
That guard is wired into the report header's Submit button (SubmitPrimaryAction.tsx:64-72, which disables the button via isDisabled), but it is not wired into the report preview's Submit button.
The report preview path instead only checks hasSubmissionBlockingViolations, and isSubmissionBlockingViolation treats onlysmartscanFailed and noRoute as blocking. So for any normal violation (over limit, missing category, missing receipt, etc.) under strict rules, the preview's SubmitActionButton renders enabled and calls submitReport() with no guard.
Generic error on click:onPress calls submitReport() unconditionally → backend blocks it under strict enforcement → App surfaces the generic Unexpected error. Please try again.
Violations not shown: nothing in this path surfaces which violation is blocking submission.
What changes do you think we should make in order to solve the problem?
Apply the same guard the header Submit button already uses to the report preview Submit button. In SubmitActionButton.tsx, call useStrictPolicyRules() and shouldBlockSubmitDueToStrictPolicyRules(...) (mirroring SubmitPrimaryAction.tsx), pass the result to AnimatedSubmitButton's isDisabled, and early-return from onPress when blocked. This keeps both Submit buttons consistent and prevents the doomed submit + generic error.
To also satisfy "clearly display the specific violation(s)", surface the blocking violations on the report (RBR) so the user knows what to fix before submitting.
What alternative solutions did you explore? (Optional)
Alternatively, thread areStrictPolicyRulesEnabled into canSubmit so the SUBMIT action isn't selected at all. However, the established header pattern shows but disables the button (clearer UX), so disabling in SubmitActionButton is the more consistent choice.
Confidence: High — root cause is backed by code at each step, and the data needed for the fix already exists in App. This is a frontend-only fix (no backend change required).
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/92367) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
🚨 Edited by proposal-police: This proposal was edited at 2026-06-02 13:29:48 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a domain has Strictly Enforce Workflow Rules (SecurityGroup.enableStrictPolicyRules) enabled and a report has blocking policy violations, the Submit button on the money-request report preview stays enabled. Clicking it fires SubmitReport, the backend rejects it, and the user only sees the generic "Unexpected error. Please try again later." — the actual violation detail is never surfaced. Expected: the button is disabled while blocking violations exist, and the specific violation is shown.
What is the root cause of that problem?
There are two Submit buttons, and only one of them is wired to the strict-policy gate.
Working path — report header (SubmitPrimaryAction). It reads the flag with useStrictPolicyRules(), computes shouldBlockSubmit from the existing helper, early-returns in handleSubmit, and passes isDisabled={shouldBlockSubmit}:
Broken path — report preview (SubmitActionButton). The same button on the preview card renders AnimatedSubmitButton with no isDisabled prop and no guard in onPress — even though every input the gate needs is already in scope (transactionViolations L39, policy L34, currentUserAccountID/currentUserEmail L29-30, transactions L44-46, isOffline L42):
Which button shows is decided by getReportPreviewAction → canSubmit. But canSubmit's blocking check uses hasSubmissionBlockingViolations, which only treats SMARTSCAN_FAILED and NO_ROUTE as blocking — it has no visibility into strict-policy / workflow-rule violations at all:
So getReportPreviewAction returns SUBMIT, and the rendered button never disables itself → Submit stays enabled. The strict-rules helper that should gate it already exists and is what the header uses:
Second symptom — generic error. When Submit is clicked anyway, submitReport() ships a pre-built failureData that hardcodes the report-action error to iou.error.other for non-DEW policies. Because the failure message is fixed client-side, the backend's real violation text is overwritten by the generic string:
en.ts — iou.error.other: 'Unexpected error. Please try again later.'
What changes do you think we should make in order to solve the problem?
Fix A (primary) — gate the preview Submit button, mirroring the header. Reuse the exact helpers SubmitPrimaryAction already uses, inside SubmitActionButton.tsx. All data is already in scope; only the useStrictPolicyRules hook needs importing.
AnimatedSubmitButton already forwards isDisabled to the underlying Button, so no further wiring is needed. transactionViolations here is the full TRANSACTION_VIOLATIONS collection — the same shape the helper expects in SubmitPrimaryAction.
Fix B (secondary) — surface the real violation instead of the generic message. For online non-DEW failures, stop overwriting the report-action error with iou.error.other; let the backend's response.onyxData carry the specific violation, and keep the generic message only as an offline fallback. isOffline is already in scope in SubmitActionButton (L42) and would be threaded into submitReport:
// src/libs/actions/IOU/ReportWorkflow.ts (~L1462-L1472)
- } else {+ } else if (isOffline) {
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`,
value: {[optimisticSubmittedReportAction.reportActionID]: {errors: getMicroSecondOnyxErrorWithTranslationKey('iou.error.other')}},
});
+ } else {+ // Online: rely on backend response.onyxData to set the specific violation error; just roll back the optimistic action.+ failureData.push({+ onyxMethod: Onyx.METHOD.MERGE,+ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport.reportID}`,+ value: {[optimisticSubmittedReportAction.reportActionID]: null},+ });
}
Fix B depends on SubmitReport actually returning the violation detail in response.onyxData on a strict-policy rejection. That is a backend behavior I could not confirm from this repo — confirm before relying on it. If the backend does not surface it, Fix A alone still resolves the primary issue (button correctly disabled, so the failing submit no longer happens).
Run npx prettier --write on changed files, then npm run lint-changed, npm run typecheck, and npm run react-compiler-compliance-check check-changed (SubmitActionButton is a modified component).
Test:
Domain with Strictly Enforce Workflow Rules enabled; a report whose transaction has a blocking policy violation.
Open the report preview card → Submit button is disabled (matches the header button). Before the fix it is enabled/clickable.
Clear the violation → button re-enables.
Regression: report with no violations under strict rules still submits from the preview; a domain without strict rules keeps current behavior.
(Fix B, online) Force a server rejection → the report action shows the specific violation text, not "Unexpected error…".
(Fix B, offline) Submit offline → generic iou.error.other fallback still shows and rolls back on reconnect.
What alternative solutions did you explore? (Optional)
Centralize the gate in canSubmit / getReportPreviewAction so the SUBMIT action is never emitted for blocked reports (button doesn't render at all). Cleaner long-term and removes duplicate gating between the two buttons, but it changes a widely-used utility signature (canSubmit has no areStrictPolicyRulesEnabled param) and every call site, raising regression surface. Fix A is the lower-risk change and matches the existing header pattern; this can follow as a refactor.
Extend hasSubmissionBlockingViolations to include strict-policy violations. Rejected as primary: it has no access to areStrictPolicyRulesEnabled and would conflate always-blocking violations (SMARTSCAN_FAILED/NO_ROUTE) with rules-only-blocking ones.
Add a new client-side violation-aware error string instead of using backend text. Rejected: the backend already produces accurate, localized violation detail — hardcoding another client message just re-creates the masking problem.
The money-request report has two surfaces with a Submit button — the report header and the chat-thread report preview — and they share the same submitReport action but only one of them enforces the "Strictly Enforce Workspace Rules" domain setting.
The report header's button (SubmitPrimaryAction) consults the useStrictPolicyRules hook and shouldBlockSubmitDueToStrictPolicyRules / shouldBlockSubmitDueToPreventSelfApproval, ORs the result into shouldBlockSubmit, and passes it to <AnimatedSubmitButton isDisabled={shouldBlockSubmit} />:
The report-preview's button (SubmitActionButton, rendered inside MoneyRequestReportPreview when getReportPreviewAction returns SUBMIT) does NOT use that hook or those helpers at all — it goes straight from onPress to submitReport with no isDisabled and no early return:
canSubmit upstream in ReportPreviewActionUtils doesn't gate on domain strict rules either — it only filters out transactions whose violations pass isSubmissionBlockingViolation, a fixed per-transaction subset. Domain "Strictly Enforce" is supposed to promote every workspace-rule violation to blocking, but neither canSubmit nor SubmitActionButton consult securityGroup.enableStrictPolicyRules:
So when a user under a domain with strict rules opens a report with non-isSubmissionBlockingViolation workspace-rule violations, canSubmit returns true → getReportPreviewAction picks SUBMIT → the preview renders SubmitActionButton with no guard → click fires submitReport → the backend rejects strict-rule violations and surfaces the generic "Unexpected error. Please try again." path because the client never short-circuited locally.
What changes do you think we should make in order to solve the problem?
I'd port the same two guards from SubmitPrimaryAction into SubmitActionButton, so the preview button matches the header's behavior — disabled when strict rules + violations or self-approval would block, and bails out of onPress instead of calling submitReport:
+import useStrictPolicyRules from '@hooks/useStrictPolicyRules';+import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport';-import {hasViolations as hasViolationsReportUtils} from '@libs/ReportUtils';+import {hasViolations as hasViolationsReportUtils, shouldBlockSubmitDueToPreventSelfApproval, shouldBlockSubmitDueToStrictPolicyRules} from '@libs/ReportUtils';
...
+ const {areStrictPolicyRulesEnabled} = useStrictPolicyRules();+ const {violations: reportViolations} = useTransactionsAndViolationsForReport(iouReport?.reportID);++ const isBlockSubmitDueToStrictPolicyRules = shouldBlockSubmitDueToStrictPolicyRules(+ iouReport?.reportID,+ reportViolations,+ areStrictPolicyRulesEnabled,+ currentUserAccountID,+ currentUserEmail,+ transactions,+ );+ const isBlockSubmitDueToPreventSelfApproval = shouldBlockSubmitDueToPreventSelfApproval(iouReport, policy);+ const shouldBlockSubmit = isBlockSubmitDueToStrictPolicyRules || isBlockSubmitDueToPreventSelfApproval;
...
<AnimatedSubmitButton
success
text={translate('common.submit')}
onPress={() => {
+ if (shouldBlockSubmit) {+ return;+ }
if (hasOnlyPendingCardTransactions(transactions)) {
...
}
...
}}
+ isDisabled={shouldBlockSubmit}
isSubmittingAnimationRunning={isSubmittingAnimationRunning}
onAnimationFinish={stopAnimation}
sentryLabel={CONST.SENTRY_LABEL.REPORT_PREVIEW.SUBMIT_BUTTON}
/>
The onPress guard is defense-in-depth in case anything bypasses the disabled state (e.g. an enter-key handler), and mirrors the same if (!moneyRequestReport || shouldBlockSubmit) return; check at SubmitPrimaryAction.tsx#L78-L81. For the violation display the bug also requests, the existing in-transaction violation badges in the report preview's transaction rows already surface the offending rules — no separate copy needed; the disabled state stops the generic error path.
What alternative solutions did you explore? (Optional)
Add the strict-rules check inside canSubmit in ReportPreviewActionUtils.ts so getReportPreviewAction doesn't return SUBMIT at all — the preview would render a different action (e.g. VIEW). Rejected — it requires threading areStrictPolicyRulesEnabled (a hook-derived value) through every getReportPreviewAction caller, and the UX intent (mirroring the header) is to show a disabled Submit so users can see what's blocked, not to hide the action and leave them guessing.
Extract a shared useShouldBlockReportSubmit({report, policy, transactions, violations}) hook that both SubmitPrimaryAction and SubmitActionButton consume. Cleaner long-term and removes the duplication, but it's a refactor that touches three call sites; I'd prefer to land the bug fix first and follow up with consolidation in a separate PR.
Rely on the backend rejection and just improve the error message. Rejected — it lets the user click a "successful-looking" Submit, fires an animation, and then shows an error after the round-trip. The header already prevents this; the preview should match.
The report preview submit path does not apply the existing strict workflow rule submission blocker.
SubmitPrimaryAction, lifecycle actions, selection mode, and useOptimisticNextStep already use useStrictPolicyRules() with shouldBlockSubmitDueToStrictPolicyRules() so reports with violations are blocked when enableStrictPolicyRules is enabled. But the money request report preview path uses ReportPreviewActionUtils.canSubmit() and SubmitActionButton, which only block the narrow hasSubmissionBlockingViolations() set like SmartScan/no-route failures.
Because strict policy violations are not checked there, the preview still renders an enabled Submit button and calls submitReport(). The backend then rejects SubmitReport, and the client shows the generic failure instead of relying on the existing violation UI/next-step state.
What changes do you think we should make in order to solve the problem?
Add the strict policy blocker to the report preview submit flow.
In ReportPreviewActionButton, read areStrictPolicyRulesEnabled via useStrictPolicyRules() and calculate:
shouldBlockSubmitDueToStrictPolicyRules(...) using the preview report ID, report transactions, transaction violations, current account ID, and current email
the existing prevent-self-approval blocker if needed for parity with the primary submit action
Keep the preview action as SUBMIT when the user otherwise can submit, but pass a shouldBlockSubmit/isDisabled prop into SubmitActionButton.
In SubmitActionButton:
pass isDisabled={shouldBlockSubmit} to AnimatedSubmitButton
return early in onPress when blocked, before pending-card/RTER handling and before calling submitReport()
This prevents the failing API call and keeps the UI in the same state as the report header submit button. The report already has existing strict-rule next-step messaging and per-transaction violation rendering, so users see the actual violations to fix instead of a generic submit error.
What alternative solutions did you explore? (Optional)
We could make getReportPreviewAction() return VIEW when strict rules block submission, but that would hide the Submit affordance instead of disabling it. The expected behavior is a disabled Submit button, so the cleaner fix is to keep the submit action visible and disable/guard only the submit button.
Please re-state the problem that we are trying to solve in this issue.
For expense reports with strict workflow-rule enforcement, the report preview still offers the Submit action even when one of the report transactions has a blocking policy violation. Pressing it sends SubmitReport anyway and the failed optimistic submit action rolls back with the generic iou.error.other message.
What is the root cause of that problem?
The client-side submit eligibility checks all funnel through hasSubmissionBlockingViolations(), including the report preview button path:
ReportPreviewActionUtils.canSubmit() hides Submit only when hasSubmissionBlockingViolations(...) returns true.
ReportPreviewActionButton already subscribes to ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS and passes it into getReportPreviewAction().
ReportPrimaryActionUtils, ReportSecondaryActionUtils, and canSubmitReport() use the same blocking helper for other Submit entry points.
The problem is that hasSubmissionBlockingViolations() currently only treats smartscanFailed and noRoute as submission blockers. It ignores ordinary visible, undismissed transaction violations whose severity is CONST.VIOLATION_TYPES.VIOLATION (for example missing required category/tag/custom rule/prohibited expense style violations). When strict workflow rules make those violation records backend-blocking, the preview action still resolves to SUBMIT, the API rejects the submit, and the non-DEW failure rollback attaches iou.error.other, which is why the user sees “Unexpected error. Please try again.”
What changes do you think we should make in order to solve the problem?
Update the common submission-blocking predicate instead of adding a report-preview-only guard:
In src/libs/TransactionUtils/index.ts, change hasSubmissionBlockingViolations() to return true when an undismissed, user-visible transaction violation has type === CONST.VIOLATION_TYPES.VIOLATION, while preserving the existing explicit blockers for SMARTSCAN_FAILED and NO_ROUTE.
Keep using getTransactionViolations() so dismissed violations remain ignored. Also apply shouldShowViolation(report, policy, violation.name, currentUserEmail, true, transaction) before blocking so the submit button is not hidden for violations the current user should not see.
Because the report preview already passes transactionViolations into getReportPreviewAction(), this will make the preview button resolve to VIEW instead of SUBMIT for strict blocking violations. The same fix also keeps primary/secondary report actions and search submit eligibility aligned.
Add/update tests around:
ReportPreviewActionUtilsTest: a transaction with a visible MISSING_CATEGORY or CUSTOM_RULES violation of type VIOLATION returns VIEW, while WARNING/NOTICE still do not block.
ReportPrimaryActionUtilsTest and ReportSecondaryActionUtilsTest: Submit is not returned for a type-VIOLATION transaction violation.
ReportWorkflowTest: canSubmitReport() returns false for a report containing a type-VIOLATION transaction violation.
This addresses the enabled-button problem at the shared eligibility layer. The existing transaction preview/RBR components already render violation details from the transaction violation data, so once Submit is suppressed the user is directed to the report/transaction review UI instead of getting the generic API failure.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Open expense report + current submitter + paid group policy + one transaction with type: "violation" and visible showInReview data: report preview action is not Submit.
Same setup with type: "warning" or type: "notice": Submit eligibility is unchanged.
Dismissed or not-visible violations do not block submission.
Existing special blockers smartscanFailed and noRoute continue to block regardless of severity.
What alternative solutions did you explore? (Optional)
A narrower fix would add a second violation check only in ReportPreviewActionUtils.canSubmit() or ReportPreviewActionButton, but that would leave primary, secondary, search, and workflow submit paths inconsistent. Centralizing the behavior in hasSubmissionBlockingViolations() matches how submit eligibility is already structured.
🚨 Edited by proposal-police: This proposal was edited at 2026-06-18 16:29:58 UTC.
Proposal
What is the root cause of that problem?
When a user's domain has "Strictly Enforce Workspace Rules" enabled (SecurityGroup.enableStrictPolicyRules), submission must be blocked for any report that has violations. App already has the gate for this — shouldBlockSubmitDueToStrictPolicyRules, fed by useStrictPolicyRules — but it lives only in the components, not in the shared submit-eligibility utilities. The report header button wires it in and disables itself (SubmitPrimaryAction.tsx#L68-L76, isDisabled at #L133). Every other surface that decides "can this report be submitted?" goes through the two shared utilities, and neither is strict-rules aware:
canSubmit (report preview) — only filters hasSubmissionBlockingViolations, and isSubmissionBlockingViolation treats onlySMARTSCAN_FAILED/NO_ROUTE as blocking. So for a normal workspace-rule violation (over limit, missing category/tag/receipt, etc.), getReportPreviewAction → canSubmit returns SUBMIT and renders SubmitActionButton, which has no isDisabled and no guard in onPress → it fires submitReport(), the backend rejects under strict enforcement, and the App shows the generic Unexpected error. Please try again.
canSubmitReport (everything else) — the same gap, with the same SMARTSCAN/NO_ROUTE-only check at ReportWorkflow.ts#L256-L267. This is the root the other proposals miss: canSubmitReport is not preview-only. It also drives:
Search page bulk Submit — SearchUIUtils.ts#L2433-L2438 pushes ACTION_TYPES.SUBMIT straight from canSubmitReport, so the bulk Submit action stays available for violating reports under strict rules.
So: strict-rules gate exists but is component-local → the shared canSubmit/canSubmitReport utilities never consult it → the preview button (issue symptom), the Search bulk action, and the LHN badge all offer Submit for violating reports → click → backend rejection → generic error. The header looks correct, which is exactly why this is "hard to reproduce" (depends on which Submit entry point you use).
What changes do you think we should make in order to solve the problem?
Centralize the gate in the two shared eligibility utilities instead of patching one button — that fixes the preview button and the Search bulk action and the LHN badge in one place, and keeps every Submit surface consistent.
With canSubmit returning false, getReportPreviewAction falls through to VIEW, so the doomed Submit button is never rendered on the preview (matches the expected "Submit should not be actionable"). The Search bulk-submit option and the LHN SUBMIT badge drop off automatically because they read canSubmitReport.
For the "display the specific violation(s)" half of the expected result, the report already carries the violations; surfacing them as the report's RBR (red brick road) so the user sees what to fix is the natural follow-up — minor changes/improvements can be discussed in the PR phase.
What alternative solutions did you explore? (Optional)
Mirror SubmitPrimaryAction purely inside SubmitActionButton.tsx (add the hook + shouldBlockSubmitDueToStrictPolicyRules and pass isDisabled). This is the smallest diff and fixes the exact button in the report, but it leaves canSubmitReport's other consumers — the Search page bulk Submit and the LHN SUBMIT badge — still offering Submit for the same violating report under strict rules, i.e. it patches the symptom on one surface and duplicates the guard per component. Centralizing in canSubmit/canSubmitReport removes the duplication and closes all three surfaces at once.
The strict workflow rules client-side guard was added for the main report header Submit button in PR #90363, but the same guard was not added to the report preview Submit path.
The main report header path correctly reads the domain setting via useStrictPolicyRules() and blocks submit with shouldBlockSubmitDueToStrictPolicyRules():
So report preview can show Submit even when strict domain rules should block the report. Clicking that preview Submit then calls submitReport() without a strict-rules guard, so the backend rejects it and the user sees the generic error.
Also add the same guard to MoneyRequestReportPreview/SubmitActionButton.tsx before calling submitReport(), so a stale preview button cannot submit while strict-rule violations are present.
Finally, add a regression test in tests/actions/ReportPreviewActionUtilsTest.ts: when areStrictPolicyRulesEnabled is true and the report has violations, getReportPreviewAction() should not return SUBMIT.
What alternative solutions did you explore? (Optional)
Only changing SubmitActionButton would stop the API call, but the preview would still show Submit incorrectly.
Only relying on the backend rejection keeps the current generic error and does not explain the specific violations before the user clicks Submit.
📣 @eswar5678! 📣
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:
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>
@mallenexpensify Hi! Just checking in on payment for this one. The regression period passed with no regressions (confirmed by @mananjadhav above), and my contributor details are already on file. I'm ready to accept the Upwork offer whenever it's sent. Thank you!
@mallenexpensify Thank you, and no worries about the delay! I've applied to the Upwork job you posted. Ready to accept the offer whenever you're able to send it.
Activity
MelvinBot commentedon Jun 2, 2026
The report preview Submit button ignores the "Strictly Enforce Workspace Rules" domain setting, so it stays enabled for reports with policy violations. Clicking it fires
submitReport()anyway, the backend rejects it, and the user gets the genericUnexpected error. Please try again.(en.ts:1512). The report header Submit button already handles this correctly — which is likely why this is hard to reproduce (depends on which Submit button you click).Proposal
What is the root cause of that problem?
App already has a dedicated guard,
shouldBlockSubmitDueToStrictPolicyRules, which blocks submission when the user's domain has strict rules enabled (read viauseStrictPolicyRules) and the report has any violation.That guard is wired into the report header's Submit button (
SubmitPrimaryAction.tsx:64-72, which disables the button viaisDisabled), but it is not wired into the report preview's Submit button.The report preview path instead only checks
hasSubmissionBlockingViolations, andisSubmissionBlockingViolationtreats onlysmartscanFailedandnoRouteas blocking. So for any normal violation (over limit, missing category, missing receipt, etc.) under strict rules, the preview'sSubmitActionButtonrenders enabled and callssubmitReport()with no guard.Symptom-by-symptom evidence
getReportPreviewAction→canSubmitreturns the SUBMIT action because the violation isn'tsmartscanFailed/noRoute. The renderedSubmitActionButton.tsx:60-90has noisDisabledprop and no strict-rules guard ononPress.onPresscallssubmitReport()unconditionally → backend blocks it under strict enforcement → App surfaces the genericUnexpected error. Please try again.What changes do you think we should make in order to solve the problem?
Apply the same guard the header Submit button already uses to the report preview Submit button. In
SubmitActionButton.tsx, calluseStrictPolicyRules()andshouldBlockSubmitDueToStrictPolicyRules(...)(mirroringSubmitPrimaryAction.tsx), pass the result toAnimatedSubmitButton'sisDisabled, and early-return fromonPresswhen blocked. This keeps both Submit buttons consistent and prevents the doomed submit + generic error.To also satisfy "clearly display the specific violation(s)", surface the blocking violations on the report (RBR) so the user knows what to fix before submitting.
What alternative solutions did you explore? (Optional)
Alternatively, thread
areStrictPolicyRulesEnabledintocanSubmitso the SUBMIT action isn't selected at all. However, the established header pattern shows but disables the button (clearer UX), so disabling inSubmitActionButtonis the more consistent choice.Confidence: High — root cause is backed by code at each step, and the data needed for the fix already exists in App. This is a frontend-only fix (no backend change required).
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/92367)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
kamronbek04 commentedon Jun 2, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-02 13:29:48 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a domain has Strictly Enforce Workflow Rules (
SecurityGroup.enableStrictPolicyRules) enabled and a report has blocking policy violations, the Submit button on the money-request report preview stays enabled. Clicking it firesSubmitReport, the backend rejects it, and the user only sees the generic "Unexpected error. Please try again later." — the actual violation detail is never surfaced. Expected: the button is disabled while blocking violations exist, and the specific violation is shown.What is the root cause of that problem?
There are two Submit buttons, and only one of them is wired to the strict-policy gate.
Working path — report header (
SubmitPrimaryAction). It reads the flag withuseStrictPolicyRules(), computesshouldBlockSubmitfrom the existing helper, early-returns inhandleSubmit, and passesisDisabled={shouldBlockSubmit}:SubmitPrimaryAction.tsx#L60-L69,#L75,#L113Broken path — report preview (
SubmitActionButton). The same button on the preview card rendersAnimatedSubmitButtonwith noisDisabledprop and no guard inonPress— even though every input the gate needs is already in scope (transactionViolationsL39,policyL34,currentUserAccountID/currentUserEmailL29-30,transactionsL44-46,isOfflineL42):SubmitActionButton.tsx#L58-L84Which button shows is decided by
getReportPreviewAction→canSubmit. ButcanSubmit's blocking check useshasSubmissionBlockingViolations, which only treatsSMARTSCAN_FAILEDandNO_ROUTEas blocking — it has no visibility into strict-policy / workflow-rule violations at all:ReportPreviewActionUtils.ts#L53,#L244-L245TransactionUtils/index.ts#L2825-L2835So
getReportPreviewActionreturnsSUBMIT, and the rendered button never disables itself → Submit stays enabled. The strict-rules helper that should gate it already exists and is what the header uses:ReportUtils.ts#L9308-L9320(shouldBlockSubmitDueToStrictPolicyRules→hasAnyViolations)Second symptom — generic error. When Submit is clicked anyway,
submitReport()ships a pre-builtfailureDatathat hardcodes the report-action error toiou.error.otherfor non-DEW policies. Because the failure message is fixed client-side, the backend's real violation text is overwritten by the generic string:ReportWorkflow.ts#L1462-L1472(error set at L1468),API.writeat#L1511en.ts—iou.error.other: 'Unexpected error. Please try again later.'What changes do you think we should make in order to solve the problem?
Fix A (primary) — gate the preview Submit button, mirroring the header. Reuse the exact helpers
SubmitPrimaryActionalready uses, insideSubmitActionButton.tsx. All data is already in scope; only theuseStrictPolicyRuleshook needs importing.AnimatedSubmitButtonalready forwardsisDisabledto the underlyingButton, so no further wiring is needed.transactionViolationshere is the fullTRANSACTION_VIOLATIONScollection — the same shape the helper expects inSubmitPrimaryAction.Fix B (secondary) — surface the real violation instead of the generic message. For online non-DEW failures, stop overwriting the report-action error with
iou.error.other; let the backend'sresponse.onyxDatacarry the specific violation, and keep the generic message only as an offline fallback.isOfflineis already in scope inSubmitActionButton(L42) and would be threaded intosubmitReport:Run
npx prettier --writeon changed files, thennpm run lint-changed,npm run typecheck, andnpm run react-compiler-compliance-check check-changed(SubmitActionButtonis a modified component).Test:
iou.error.otherfallback still shows and rolls back on reconnect.What alternative solutions did you explore? (Optional)
canSubmit/getReportPreviewActionso the SUBMIT action is never emitted for blocked reports (button doesn't render at all). Cleaner long-term and removes duplicate gating between the two buttons, but it changes a widely-used utility signature (canSubmithas noareStrictPolicyRulesEnabledparam) and every call site, raising regression surface. Fix A is the lower-risk change and matches the existing header pattern; this can follow as a refactor.hasSubmissionBlockingViolationsto include strict-policy violations. Rejected as primary: it has no access toareStrictPolicyRulesEnabledand would conflate always-blocking violations (SMARTSCAN_FAILED/NO_ROUTE) with rules-only-blocking ones.David-2002065 commentedon Jun 2, 2026
Proposal
What is the root cause of that problem?
The money-request report has two surfaces with a Submit button — the report header and the chat-thread report preview — and they share the same
submitReportaction but only one of them enforces the "Strictly Enforce Workspace Rules" domain setting.The report header's button (
SubmitPrimaryAction) consults theuseStrictPolicyRuleshook andshouldBlockSubmitDueToStrictPolicyRules/shouldBlockSubmitDueToPreventSelfApproval, ORs the result intoshouldBlockSubmit, and passes it to<AnimatedSubmitButton isDisabled={shouldBlockSubmit} />:https://github.com/Expensify/App/blob/main/src/components/MoneyReportHeaderPrimaryAction/SubmitPrimaryAction.tsx#L37-L72
https://github.com/Expensify/App/blob/main/src/components/MoneyReportHeaderPrimaryAction/SubmitPrimaryAction.tsx#L116-L125
The report-preview's button (
SubmitActionButton, rendered insideMoneyRequestReportPreviewwhengetReportPreviewActionreturnsSUBMIT) does NOT use that hook or those helpers at all — it goes straight fromonPresstosubmitReportwith noisDisabledand no early return:https://github.com/Expensify/App/blob/main/src/components/ReportActionItem/MoneyRequestReportPreview/SubmitActionButton.tsx#L27-L91
canSubmitupstream inReportPreviewActionUtilsdoesn't gate on domain strict rules either — it only filters out transactions whose violations passisSubmissionBlockingViolation, a fixed per-transaction subset. Domain "Strictly Enforce" is supposed to promote every workspace-rule violation to blocking, but neithercanSubmitnorSubmitActionButtonconsultsecurityGroup.enableStrictPolicyRules:https://github.com/Expensify/App/blob/main/src/libs/ReportPreviewActionUtils.ts#L27-L61
https://github.com/Expensify/App/blob/main/src/hooks/useStrictPolicyRules.ts#L14-L35
https://github.com/Expensify/App/blob/main/src/libs/ReportUtils.ts#L9346-L9362
So when a user under a domain with strict rules opens a report with non-
isSubmissionBlockingViolationworkspace-rule violations,canSubmitreturns true →getReportPreviewActionpicksSUBMIT→ the preview rendersSubmitActionButtonwith no guard → click firessubmitReport→ the backend rejects strict-rule violations and surfaces the generic "Unexpected error. Please try again." path because the client never short-circuited locally.What changes do you think we should make in order to solve the problem?
I'd port the same two guards from
SubmitPrimaryActionintoSubmitActionButton, so the preview button matches the header's behavior — disabled when strict rules + violations or self-approval would block, and bails out ofonPressinstead of callingsubmitReport:The
onPressguard is defense-in-depth in case anything bypasses the disabled state (e.g. an enter-key handler), and mirrors the sameif (!moneyRequestReport || shouldBlockSubmit) return;check atSubmitPrimaryAction.tsx#L78-L81. For the violation display the bug also requests, the existing in-transaction violation badges in the report preview's transaction rows already surface the offending rules — no separate copy needed; the disabled state stops the generic error path.What alternative solutions did you explore? (Optional)
canSubmitinReportPreviewActionUtils.tssogetReportPreviewActiondoesn't returnSUBMITat all — the preview would render a different action (e.g.VIEW). Rejected — it requires threadingareStrictPolicyRulesEnabled(a hook-derived value) through everygetReportPreviewActioncaller, and the UX intent (mirroring the header) is to show a disabled Submit so users can see what's blocked, not to hide the action and leave them guessing.useShouldBlockReportSubmit({report, policy, transactions, violations})hook that bothSubmitPrimaryActionandSubmitActionButtonconsume. Cleaner long-term and removes the duplication, but it's a refactor that touches three call sites; I'd prefer to land the bug fix first and follow up with consolidation in a separate PR.moxw commentedon Jun 2, 2026
Proposal
What is the root cause of that problem?
The report preview submit path does not apply the existing strict workflow rule submission blocker.
SubmitPrimaryAction, lifecycle actions, selection mode, anduseOptimisticNextStepalready useuseStrictPolicyRules()withshouldBlockSubmitDueToStrictPolicyRules()so reports with violations are blocked whenenableStrictPolicyRulesis enabled. But the money request report preview path usesReportPreviewActionUtils.canSubmit()andSubmitActionButton, which only block the narrowhasSubmissionBlockingViolations()set like SmartScan/no-route failures.Because strict policy violations are not checked there, the preview still renders an enabled Submit button and calls
submitReport(). The backend then rejectsSubmitReport, and the client shows the generic failure instead of relying on the existing violation UI/next-step state.What changes do you think we should make in order to solve the problem?
Add the strict policy blocker to the report preview submit flow.
In
ReportPreviewActionButton, readareStrictPolicyRulesEnabledviauseStrictPolicyRules()and calculate:shouldBlockSubmitDueToStrictPolicyRules(...)using the preview report ID, report transactions, transaction violations, current account ID, and current emailKeep the preview action as
SUBMITwhen the user otherwise can submit, but pass ashouldBlockSubmit/isDisabledprop intoSubmitActionButton.In
SubmitActionButton:isDisabled={shouldBlockSubmit}toAnimatedSubmitButtononPresswhen blocked, before pending-card/RTER handling and before callingsubmitReport()This prevents the failing API call and keeps the UI in the same state as the report header submit button. The report already has existing strict-rule next-step messaging and per-transaction violation rendering, so users see the actual violations to fix instead of a generic submit error.
What alternative solutions did you explore? (Optional)
We could make
getReportPreviewAction()returnVIEWwhen strict rules block submission, but that would hide the Submit affordance instead of disabling it. The expected behavior is a disabled Submit button, so the cleaner fix is to keep the submit action visible and disable/guard only the submit button.KJ21-ENG commentedon Jun 2, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
For expense reports with strict workflow-rule enforcement, the report preview still offers the Submit action even when one of the report transactions has a blocking policy violation. Pressing it sends
SubmitReportanyway and the failed optimistic submit action rolls back with the genericiou.error.othermessage.What is the root cause of that problem?
The client-side submit eligibility checks all funnel through
hasSubmissionBlockingViolations(), including the report preview button path:ReportPreviewActionUtils.canSubmit()hides Submit only whenhasSubmissionBlockingViolations(...)returns true.ReportPreviewActionButtonalready subscribes toONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONSand passes it intogetReportPreviewAction().ReportPrimaryActionUtils,ReportSecondaryActionUtils, andcanSubmitReport()use the same blocking helper for other Submit entry points.The problem is that
hasSubmissionBlockingViolations()currently only treatssmartscanFailedandnoRouteas submission blockers. It ignores ordinary visible, undismissed transaction violations whose severity isCONST.VIOLATION_TYPES.VIOLATION(for example missing required category/tag/custom rule/prohibited expense style violations). When strict workflow rules make those violation records backend-blocking, the preview action still resolves toSUBMIT, the API rejects the submit, and the non-DEW failure rollback attachesiou.error.other, which is why the user sees “Unexpected error. Please try again.”What changes do you think we should make in order to solve the problem?
Update the common submission-blocking predicate instead of adding a report-preview-only guard:
src/libs/TransactionUtils/index.ts, changehasSubmissionBlockingViolations()to return true when an undismissed, user-visible transaction violation hastype === CONST.VIOLATION_TYPES.VIOLATION, while preserving the existing explicit blockers forSMARTSCAN_FAILEDandNO_ROUTE.getTransactionViolations()so dismissed violations remain ignored. Also applyshouldShowViolation(report, policy, violation.name, currentUserEmail, true, transaction)before blocking so the submit button is not hidden for violations the current user should not see.transactionViolationsintogetReportPreviewAction(), this will make the preview button resolve toVIEWinstead ofSUBMITfor strict blocking violations. The same fix also keeps primary/secondary report actions and search submit eligibility aligned.ReportPreviewActionUtilsTest: a transaction with a visibleMISSING_CATEGORYorCUSTOM_RULESviolation of typeVIOLATIONreturnsVIEW, whileWARNING/NOTICEstill do not block.ReportPrimaryActionUtilsTestandReportSecondaryActionUtilsTest: Submit is not returned for a type-VIOLATIONtransaction violation.ReportWorkflowTest:canSubmitReport()returns false for a report containing a type-VIOLATIONtransaction violation.This addresses the enabled-button problem at the shared eligibility layer. The existing transaction preview/RBR components already render violation details from the transaction violation data, so once Submit is suppressed the user is directed to the report/transaction review UI instead of getting the generic API failure.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
type: "violation"and visibleshowInReviewdata: report preview action is not Submit.type: "warning"ortype: "notice": Submit eligibility is unchanged.smartscanFailedandnoRoutecontinue to block regardless of severity.What alternative solutions did you explore? (Optional)
A narrower fix would add a second violation check only in
ReportPreviewActionUtils.canSubmit()orReportPreviewActionButton, but that would leave primary, secondary, search, and workflow submit paths inconsistent. Centralizing the behavior inhasSubmissionBlockingViolations()matches how submit eligibility is already structured.yusufdeveloper2903 commentedon Jun 2, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-18 16:29:58 UTC.
Proposal
What is the root cause of that problem?
When a user's domain has "Strictly Enforce Workspace Rules" enabled (
SecurityGroup.enableStrictPolicyRules), submission must be blocked for any report that has violations. App already has the gate for this —shouldBlockSubmitDueToStrictPolicyRules, fed byuseStrictPolicyRules— but it lives only in the components, not in the shared submit-eligibility utilities. The report header button wires it in and disables itself (SubmitPrimaryAction.tsx#L68-L76,isDisabledat #L133). Every other surface that decides "can this report be submitted?" goes through the two shared utilities, and neither is strict-rules aware:canSubmit(report preview) — only filtershasSubmissionBlockingViolations, andisSubmissionBlockingViolationtreats onlySMARTSCAN_FAILED/NO_ROUTEas blocking. So for a normal workspace-rule violation (over limit, missing category/tag/receipt, etc.),getReportPreviewAction→canSubmitreturnsSUBMITand rendersSubmitActionButton, which has noisDisabledand no guard inonPress→ it firessubmitReport(), the backend rejects under strict enforcement, and the App shows the genericUnexpected error. Please try again.canSubmitReport(everything else) — the same gap, with the same SMARTSCAN/NO_ROUTE-only check atReportWorkflow.ts#L256-L267. This is the root the other proposals miss:canSubmitReportis not preview-only. It also drives:SearchUIUtils.ts#L2433-L2438pushesACTION_TYPES.SUBMITstraight fromcanSubmitReport, so the bulk Submit action stays available for violating reports under strict rules.SUBMITbadge —getBadgeFromIOUReport→canSubmitAndIsAwaitingForCurrentUsercallscanSubmitReportatReportUtils.ts#L3010, so the green "Submit" badge is shown too.So: strict-rules gate exists but is component-local → the shared
canSubmit/canSubmitReportutilities never consult it → the preview button (issue symptom), the Search bulk action, and the LHN badge all offer Submit for violating reports → click → backend rejection → generic error. The header looks correct, which is exactly why this is "hard to reproduce" (depends on which Submit entry point you use).What changes do you think we should make in order to solve the problem?
Centralize the gate in the two shared eligibility utilities instead of patching one button — that fixes the preview button and the Search bulk action and the LHN badge in one place, and keeps every Submit surface consistent.
areStrictPolicyRulesEnabledargument intocanSubmitandcanSubmitReport, and short-circuit tofalsewhenshouldBlockSubmitDueToStrictPolicyRulesis true (it already encapsulatesenableStrictPolicyRules+hasAnyViolations— already in scope, the exact helper the header uses). The value comes from the existinguseStrictPolicyRuleshook at the component callers (ReportPreviewActionButton.tsx#L127-L142and the Search action builder).canSubmitreturningfalse,getReportPreviewActionfalls through toVIEW, so the doomed Submit button is never rendered on the preview (matches the expected "Submit should not be actionable"). The Search bulk-submit option and the LHN SUBMIT badge drop off automatically because they readcanSubmitReport.What alternative solutions did you explore? (Optional)
Mirror
SubmitPrimaryActionpurely insideSubmitActionButton.tsx(add the hook +shouldBlockSubmitDueToStrictPolicyRulesand passisDisabled). This is the smallest diff and fixes the exact button in the report, but it leavescanSubmitReport's other consumers — the Search page bulk Submit and the LHN SUBMIT badge — still offering Submit for the same violating report under strict rules, i.e. it patches the symptom on one surface and duplicates the guard per component. Centralizing incanSubmit/canSubmitReportremoves the duplication and closes all three surfaces at once.mukhrr commentedon Jun 2, 2026
Proposal
What is the root cause of that problem?
The strict workflow rules client-side guard was added for the main report header Submit button in PR #90363, but the same guard was not added to the report preview Submit path.
The main report header path correctly reads the domain setting via
useStrictPolicyRules()and blocks submit withshouldBlockSubmitDueToStrictPolicyRules():App/src/components/MoneyReportHeaderPrimaryAction/SubmitPrimaryAction.tsx
Lines 15 to 20 in 337510f
App/src/components/MoneyReportHeaderPrimaryAction/SubmitPrimaryAction.tsx
Lines 37 to 72 in 337510f
App/src/components/MoneyReportHeaderPrimaryAction/SubmitPrimaryAction.tsx
Lines 78 to 80 in 337510f
App/src/components/MoneyReportHeaderPrimaryAction/SubmitPrimaryAction.tsx
Line 123 in 337510f
The helper itself says that when the domain has “strictly enforce workspace rules” enabled, reports with violations cannot be submitted:
App/src/libs/ReportUtils.ts
Lines 9358 to 9374 in 337510f
But the report preview action path still only checks
hasSubmissionBlockingViolations()inReportPreviewActionUtils.canSubmit():App/src/libs/ReportPreviewActionUtils.ts
Lines 27 to 60 in 337510f
Then
getReportPreviewAction()returnsSUBMITfrom that incomplete check:App/src/libs/ReportPreviewActionUtils.ts
Lines 189 to 242 in 337510f
So report preview can show Submit even when strict domain rules should block the report. Clicking that preview Submit then calls
submitReport()without a strict-rules guard, so the backend rejects it and the user sees the generic error.App/src/components/ReportActionItem/MoneyRequestReportPreview/SubmitActionButton.tsx
Lines 27 to 93 in 337510f
What changes do you think we should make in order to solve the problem?
Make the report preview use the same strict-rules guard as the main report header Submit button.
In
ReportPreviewActionButton.tsx, read strict rules and pass them intogetReportPreviewAction():In
ReportPreviewActionUtils.ts, add the strict-rules param and blockSUBMITbeforecanSubmit()returns true:Also add the same guard to
MoneyRequestReportPreview/SubmitActionButton.tsxbefore callingsubmitReport(), so a stale preview button cannot submit while strict-rule violations are present.Finally, add a regression test in
tests/actions/ReportPreviewActionUtilsTest.ts: whenareStrictPolicyRulesEnabledis true and the report has violations,getReportPreviewAction()should not returnSUBMIT.What alternative solutions did you explore? (Optional)
Only changing
SubmitActionButtonwould stop the API call, but the preview would still show Submit incorrectly.Only relying on the backend rejection keeps the current generic error and does not explain the specific violations before the user clicks Submit.
melvin-bot commentedon Jun 2, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (
External)wildan-m commentedon Jun 2, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
102 remaining items
melvin-bot commentedon Sep 16, 2026
📣 @eswar5678! 📣
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:
Format:
kamronbek04 commentedon Sep 18, 2026
@mallenexpensify Hi! Just checking in on payment for this one. The regression period passed with no regressions (confirmed by @mananjadhav above), and my contributor details are already on file. I'm ready to accept the Upwork offer whenever it's sent. Thank you!
melvin-bot commentedon Sep 18, 2026
@mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
mallenexpensify commentedon Sep 21, 2026
Payment Summary
Contributor: @kamronbek04 paid $250 via Upwork
Contributor+: @mananjadhav due $250 via NewDot
@kamronbek04 can you please apply to the job in Upwork and tag me in a comment, once you have?
https://www.upwork.com/jobs/~022102163351717022853
Apologies for the delay in payment.
kamronbek04 commentedon Sep 22, 2026
@mallenexpensify Thank you, and no worries about the delay! I've applied to the Upwork job you posted. Ready to accept the offer whenever you're able to send it.
mallenexpensify commentedon Sep 22, 2026
@kamronbek04 can you please accept the job below? Please reply here and tag me once you have.
https://www.upwork.com/jobs/~022102163351717022853
kamronbek04 commentedon Sep 23, 2026
@mallenexpensify Accepted, thank you! I've also submitted the work for payment on the contract. Let me know if anything else is needed from my side.
garrettmknight commentedon Sep 24, 2026
$250 approved for @mananjadhav
mallenexpensify commentedon Sep 24, 2026
@kamronbek04 paid, summary updated above. Thx. Now that you've been paid once, the process should be quicker in the future.