Skip to content

[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

Closed

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


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:

  1. Configure a domain with Strictly Enforce Workflow Rules enabled.
  2. Create or open a report containing one or more policy violations that block submission.
  3. Open the report preview.
  4. 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:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

The screenshot for the issue is in Slack thread

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 2, 2026
  2. MelvinBot commented on Jun 2, 2026

    @MelvinBot
    Contributor

    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).

    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 via useStrictPolicyRules) 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 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 only smartscanFailed 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.

    Symptom-by-symptom evidence
    • Submit stays enabled: getReportPreviewAction → canSubmit returns the SUBMIT action because the violation isn't smartscanFailed/noRoute. The rendered SubmitActionButton.tsx:60-90 has no isDisabled prop and no strict-rules guard on onPress.
    • 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.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 2, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jun 2, 2026
  5. kamronbek04 commented on Jun 2, 2026

    @kamronbek04
    Contributor

    🚨 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:

    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.

    // src/components/ReportActionItem/MoneyRequestReportPreview/SubmitActionButton.tsx
    -import {hasViolations as hasViolationsReportUtils} from '@libs/ReportUtils';
    +import {
    +    hasViolations as hasViolationsReportUtils,
    +    shouldBlockSubmitDueToPreventSelfApproval,
    +    shouldBlockSubmitDueToStrictPolicyRules,
    +} from '@libs/ReportUtils';
    +import useStrictPolicyRules from '@hooks/useStrictPolicyRules';
     ...
     function SubmitActionButton({iouReportID, isSubmittingAnimationRunning, stopAnimation, startSubmittingAnimation}: SubmitActionButtonProps) {
         ...
    +    const {areStrictPolicyRulesEnabled} = useStrictPolicyRules();
    +    const isBlockSubmitDueToStrictPolicyRules = shouldBlockSubmitDueToStrictPolicyRules(
    +        iouReport?.reportID,
    +        transactionViolations,
    +        areStrictPolicyRulesEnabled,
    +        currentUserAccountID,
    +        currentUserEmail,
    +        transactions,
    +    );
    +    const isBlockSubmitDueToPreventSelfApproval = shouldBlockSubmitDueToPreventSelfApproval(iouReport, policy);
    +    const shouldBlockSubmit = isBlockSubmitDueToStrictPolicyRules || isBlockSubmitDueToPreventSelfApproval;
         ...
         return (
             <AnimatedSubmitButton
                 success
                 text={translate('common.submit')}
    +            isDisabled={shouldBlockSubmit}
                 onPress={() => {
    +                if (shouldBlockSubmit) {
    +                    return;
    +                }
                     confirmPendingRTERAndProceed(() => {
                         submitReport({ ... });
                     });
                 }}
                 ...
             />
         );
     }

    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:

    1. Domain with Strictly Enforce Workflow Rules enabled; a report whose transaction has a blocking policy violation.
    2. Open the report preview card → Submit button is disabled (matches the header button). Before the fix it is enabled/clickable.
    3. Clear the violation → button re-enables.
    4. Regression: report with no violations under strict rules still submits from the preview; a domain without strict rules keeps current behavior.
    5. (Fix B, online) Force a server rejection → the report action shows the specific violation text, not "Unexpected error…".
    6. (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.
  6. David-2002065 commented on Jun 2, 2026

    @David-2002065
    Contributor

    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 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} />:

    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 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:

    https://github.com/Expensify/App/blob/main/src/components/ReportActionItem/MoneyRequestReportPreview/SubmitActionButton.tsx#L27-L91

    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:

    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-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)

    1. 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.
    2. 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.
    3. 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.
  7. moxw commented on Jun 2, 2026

    @moxw

    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, 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.

  8. KJ21-ENG commented on Jun 2, 2026

    @KJ21-ENG
    Contributor

    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 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:

    1. 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.
    2. 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.
    3. 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.
    4. 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.

  9. yusufdeveloper2903 commented on Jun 2, 2026

    @yusufdeveloper2903
    Contributor

    🚨 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:

    1. canSubmit (report preview) — only filters hasSubmissionBlockingViolations, and isSubmissionBlockingViolation treats only SMARTSCAN_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.

    2. 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:

    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.

    • Thread an areStrictPolicyRulesEnabled argument into canSubmit and canSubmitReport, and short-circuit to false when shouldBlockSubmitDueToStrictPolicyRules is true (it already encapsulates enableStrictPolicyRules + hasAnyViolations — already in scope, the exact helper the header uses). The value comes from the existing useStrictPolicyRules hook at the component callers (ReportPreviewActionButton.tsx#L127-L142 and the Search action builder).
    • 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.

  10. mukhrr commented on Jun 2, 2026

    @mukhrr
    Contributor

    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 with shouldBlockSubmitDueToStrictPolicyRules():

    import useStrictPolicyRules from '@hooks/useStrictPolicyRules';
    import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport';
    import {search} from '@libs/actions/Search';
    import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
    import {getFilteredReportActionsForReportView} from '@libs/ReportActionsUtils';
    import {hasViolations as hasViolationsReportUtils, shouldBlockSubmitDueToPreventSelfApproval, shouldBlockSubmitDueToStrictPolicyRules} from '@libs/ReportUtils';

    const {areStrictPolicyRulesEnabled} = useStrictPolicyRules();
    const [moneyRequestReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
    const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(moneyRequestReport?.policyID)}`);
    const [nextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${reportID}`);
    const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
    const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
    const [ownerBillingGracePeriodEnd] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
    const [allTransactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
    const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});
    const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
    const {reportActions: unfilteredReportActions} = usePaginatedReportActions(moneyRequestReport?.reportID);
    const reportActions = getFilteredReportActionsForReportView(unfilteredReportActions);
    const {transactions: reportTransactions, violations} = useTransactionsAndViolationsForReport(moneyRequestReport?.reportID);
    const transactions = Object.values(reportTransactions);
    const hasViolations = hasViolationsReportUtils(moneyRequestReport?.reportID, allTransactionViolations, accountID, email ?? '');
    const hasAnyPendingRTERViolation = hasAnyPendingRTERViolationTransactionUtils(transactions, allTransactionViolations, email ?? '', accountID, moneyRequestReport, policy);
    const handleMarkPendingRTERTransactionsAsCash = () => {
    markPendingRTERTransactionsAsCash(transactions, allTransactionViolations, reportActions);
    };
    const confirmPendingRTERAndProceed = useConfirmPendingRTERAndProceed(hasAnyPendingRTERViolation, handleMarkPendingRTERTransactionsAsCash);
    const {showConfirmModal} = useConfirmModal();
    const isBlockSubmitDueToPreventSelfApproval = shouldBlockSubmitDueToPreventSelfApproval(moneyRequestReport, policy);
    const isBlockSubmitDueToStrictPolicyRules = shouldBlockSubmitDueToStrictPolicyRules(
    moneyRequestReport?.reportID,
    violations,
    areStrictPolicyRulesEnabled,
    accountID,
    email ?? '',
    transactions,
    );
    const shouldBlockSubmit = isBlockSubmitDueToStrictPolicyRules || isBlockSubmitDueToPreventSelfApproval;

    const handleSubmit = () => {
    if (!moneyRequestReport || shouldBlockSubmit) {
    return;

    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

    if (!areStrictPolicyRulesEnabled) {
    return false;
    }
    return hasAnyViolations(reportID, transactionViolations, currentUserAccountIDParam, currentUserEmailParam, reportTransactions);
    }
    function shouldBlockSubmitDueToPreventSelfApproval(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>): boolean {
    if (!policy?.preventSelfApproval) {
    return false;
    }
    const nextApproverAccountID = getNextApproverAccountID(report);
    const isSubmitterSameAsNextApprover = isReportOwner(report) && nextApproverAccountID === report?.ownerAccountID;
    const isSubmitterSameAsApprover = isReportOwner(report) && (report?.managerID === report?.ownerAccountID || nextApproverAccountID === report?.ownerAccountID);
    return (isSubmitterSameAsNextApprover && isOpenExpenseReport(report)) || (isSubmitterSameAsApprover && isProcessingReport(report));
    }

    But the report preview action path still only checks hasSubmissionBlockingViolations() in ReportPreviewActionUtils.canSubmit():

    function canSubmit(
    report: Report,
    isReportArchived: boolean,
    currentUserAccountID: number,
    currentUserEmail: string,
    violations?: OnyxCollection<TransactionViolation[]>,
    policy?: Policy,
    transactions?: Transaction[],
    ) {
    if (isReportArchived) {
    return false;
    }
    const isExpense = isExpenseReport(report);
    const isSubmitter = isCurrentUserSubmitter(report);
    const isOpen = isOpenReport(report);
    const isAnyReceiptBeingScanned = transactions?.some((transaction) => isScanning(transaction));
    if (hasSmartScanFailedWithMissingFields(transactions ?? [], report)) {
    return false;
    }
    if (transactions?.some((transaction) => hasSubmissionBlockingViolations(transaction, violations, currentUserEmail, currentUserAccountID, report, policy))) {
    return false;
    }
    const submitToAccountID = getSubmitToAccountID(policy, report);
    if (submitToAccountID === report.ownerAccountID && policy?.preventSelfApproval) {
    return false;
    }
    return isExpense && isSubmitter && isOpen && !isAnyReceiptBeingScanned && !!transactions && transactions.length > 0;

    Then getReportPreviewAction() returns SUBMIT from that incomplete check:

    function getReportPreviewAction({
    isReportArchived,
    currentUserAccountID,
    currentUserLogin,
    report,
    policy,
    transactions,
    bankAccountList,
    invoiceReceiverPolicy,
    isPaidAnimationRunning,
    isApprovedAnimationRunning,
    isSubmittingAnimationRunning,
    isDEWSubmitPending,
    violationsData,
    reportMetadata,
    }: {
    isReportArchived: boolean;
    currentUserAccountID: number;
    currentUserLogin: string;
    report: Report | undefined;
    policy: Policy | undefined;
    transactions: Transaction[];
    bankAccountList: OnyxEntry<BankAccountList>;
    invoiceReceiverPolicy?: Policy;
    isPaidAnimationRunning?: boolean;
    isApprovedAnimationRunning?: boolean;
    isSubmittingAnimationRunning?: boolean;
    isDEWSubmitPending?: boolean;
    violationsData?: OnyxCollection<TransactionViolation[]>;
    reportMetadata: OnyxEntry<ReportMetadata>;
    }): ValueOf<typeof CONST.REPORT.REPORT_PREVIEW_ACTIONS> {
    if (!report) {
    return CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW;
    }
    // We want to have action displayed for either paid or approved animations
    if (isPaidAnimationRunning || isApprovedAnimationRunning) {
    return CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY;
    }
    if (isSubmittingAnimationRunning) {
    return CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT;
    }
    if (isAddExpenseAction(report, transactions ?? [], isReportArchived)) {
    return CONST.REPORT.REPORT_PREVIEW_ACTIONS.ADD_EXPENSE;
    }
    if (isDEWSubmitPending && isOpenReport(report)) {
    return CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW;
    }
    if (canSubmit(report, isReportArchived, currentUserAccountID, currentUserLogin, violationsData, policy, transactions)) {
    return CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT;

    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.

    function SubmitActionButton({iouReportID, isSubmittingAnimationRunning, stopAnimation, startSubmittingAnimation}: SubmitActionButtonProps) {
    const {translate} = useLocalize();
    const {showConfirmModal} = useConfirmModal();
    const currentUserDetails = useCurrentUserPersonalDetails();
    const currentUserAccountID = currentUserDetails.accountID;
    const currentUserEmail = currentUserDetails.email ?? '';
    const {isBetaEnabled} = usePermissions();
    const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`);
    const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`);
    const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
    const [iouReportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${iouReportID}`);
    const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
    const [ownerBillingGracePeriodEnd] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
    const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
    const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`);
    const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector});
    const {isOffline} = useNetwork();
    const reportTransactionsCollection = useReportTransactionsCollection(iouReportID);
    const transactions = Object.values(reportTransactionsCollection ?? {}).filter(
    (t): t is Transaction => !!t && (isOffline || t.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE),
    );
    const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
    const hasViolations = hasViolationsReportUtils(iouReport?.reportID, transactionViolations, currentUserAccountID, currentUserEmail);
    const hasAnyPendingRTERViolation = hasAnyPendingRTERViolationTransactionUtils(transactions, transactionViolations, currentUserEmail, currentUserAccountID, iouReport, policy);
    const handleMarkPendingRTERTransactionsAsCash = () => {
    markPendingRTERTransactionsAsCash(transactions, transactionViolations, Object.values(reportActions ?? {}));
    };
    const confirmPendingRTERAndProceed = useConfirmPendingRTERAndProceed(hasAnyPendingRTERViolation, handleMarkPendingRTERTransactionsAsCash);
    return (
    <AnimatedSubmitButton
    success
    text={translate('common.submit')}
    onPress={() => {
    if (hasOnlyPendingCardTransactions(transactions)) {
    showPendingCardTransactionsBlockModal(showConfirmModal, translate);
    return;
    }
    confirmPendingRTERAndProceed(() => {
    submitReport({
    expenseReport: iouReport,
    policy,
    currentUserAccountIDParam: currentUserAccountID,
    currentUserEmailParam: currentUserEmail,
    hasViolations,
    isASAPSubmitBetaEnabled,
    expenseReportCurrentNextStepDeprecated: iouReportNextStep,
    userBillingGracePeriodEnds,
    amountOwed,
    onSubmitted: startSubmittingAnimation,
    ownerBillingGracePeriodEnd,
    delegateEmail,
    });
    });
    }}
    isSubmittingAnimationRunning={isSubmittingAnimationRunning}
    onAnimationFinish={stopAnimation}
    sentryLabel={CONST.SENTRY_LABEL.REPORT_PREVIEW.SUBMIT_BUTTON}
    />
    );
    }
    export default SubmitActionButton;

    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 into getReportPreviewAction():

    +import useStrictPolicyRules from '@hooks/useStrictPolicyRules';
    
     const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
    +const {areStrictPolicyRulesEnabled} = useStrictPolicyRules();
    
     const reportPreviewAction = getReportPreviewAction({
         ...
         violationsData: transactionViolations,
    +    areStrictPolicyRulesEnabled,
     });

    In ReportPreviewActionUtils.ts, add the strict-rules param and block SUBMIT before canSubmit() returns true:

    +import {shouldBlockSubmitDueToStrictPolicyRules} from './ReportUtils';
    
     function canSubmit(
         report,
         isReportArchived,
         currentUserAccountID,
         currentUserEmail,
         violations,
         policy,
         transactions,
    +    areStrictPolicyRulesEnabled = false,
     ) {
    +    if (
    +        shouldBlockSubmitDueToStrictPolicyRules(
    +            report.reportID,
    +            violations,
    +            areStrictPolicyRulesEnabled,
    +            currentUserAccountID,
    +            currentUserEmail,
    +            transactions,
    +        )
    +    ) {
    +        return false;
    +    }
    +
         if (transactions?.some((transaction) => hasSubmissionBlockingViolations(...))) {
             return false;
         }

    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.

  11. melvin-bot commented on Jun 2, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (External)

  12. wildan-m commented on Jun 2, 2026

    @wildan-m
    Contributor

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  13. 102 remaining items

  14. melvin-bot commented on Sep 16, 2026

    @melvin-bot

    📣 @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:

    1. Make sure you've read and understood the contributing guidelines.
    2. 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.
    3. 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.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  15. kamronbek04 commented on Sep 18, 2026

    @kamronbek04
    Contributor

    @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!

  16. melvin-bot commented on Sep 18, 2026

    @melvin-bot

    @mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  17. mallenexpensify commented on Sep 21, 2026

    @mallenexpensify
    Contributor

    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.

  18. kamronbek04 commented on Sep 22, 2026

    @kamronbek04
    Contributor

    @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.

  19. mallenexpensify commented on Sep 22, 2026

    @mallenexpensify
    Contributor

    @kamronbek04 can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022102163351717022853

  20. kamronbek04 commented on Sep 23, 2026

    @kamronbek04
    Contributor

    @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.

  21. garrettmknight commented on Sep 24, 2026

    @garrettmknight
    Contributor

    $250 approved for @mananjadhav

  22. mallenexpensify commented on Sep 24, 2026

    @mallenexpensify
    Contributor

    @kamronbek04 paid, summary updated above. Thx. Now that you've been paid once, the process should be quicker in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions