Skip to content

[Due for payment 2026-09-15] After an expense with a “Company card purchases required” violation is submitted, the Fix / To-do action continues to be displayed for the expense. #99793

Closed

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number:
Reproducible in staging?: Needs Reproduction (Reproduction blocked)
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: @AndrewGable
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Create an expense that triggers the “Company card purchases required” violation.
  2. Submit the expense/report containing the violation.
  3. After the submission is completed, open the expense or relevant task/violation section.
  4. Observe the Fix / To-do action.

Expected Result:

Once the expense has been submitted, the Fix / To-do action should no longer be displayed if the “Company card purchases required” violation can no longer be resolved by the user.
(Not sure about the expected result here)

Actual Result:

The Fix / To-do action remains visible after the expense has been submitted, even though the user appears unable to resolve the “Company card purchases required” violation.

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 video for the issue is in Slack thread

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 28, 2026
  2. exfy-zapier commented on Aug 28, 2026

    @exfy-zapier

    This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989

  3. MelvinBot commented on Aug 28, 2026

    @MelvinBot
    Contributor

    Proposal

    Reproduced on web (dev NewDot). Enabled Require company cards for all purchases on a Control workspace, created a cash expense, submitted the report. The violation, the red brick road, the orange Fix pill and the Inbox To-dos entry all persist after submission, and nothing the submitter can click resolves them.

    What is the root cause of that problem?

    companyCardRequired was added as a display-only violation and was never given a visibility rule, so it is shown to everyone in every report state.

    All violation surfaces funnel through shouldShowViolation(), which carries per-violation "can this user act on it?" branches for autoReportedRejectedExpense, overAutoApprovalLimit, rter, receiptNotSmartScanned, missingAttendees and missingCategory. companyCardRequired has no branch, so it falls through to return true at line 2135.

    The only report-state filter on the brick-road path is isOpenOrProcessingReport, and processing is exactly the submitted state — so submitting does not clear it. Worse, submitting is what creates the Fix pill: reportAttributes.ts:599-613 only sets ACTION_BADGE.FIX once the green Submit action is gone.

    The submitter genuinely cannot fix it: the violation is mapped to the 'none' field (useViolations.ts:71) so it has no editable row, it renders as a non-interactive message (MoneyRequestView.tsx:1662-1668), it is not dismissible, and it has no Mark as cash / Mark as resolved / Review path. Only a workspace admin can clear it, by disabling the rule.

    What changes do you think we should make in order to solve the problem?

    Add a COMPANY_CARD_REQUIRED branch to shouldShowViolation() that returns false for the submitter once the report is no longer open, and keeps returning true for admins and approvers, who can act on it. This mirrors the existing receiptNotSmartScanned branch.

    One change fixes every surface, because useTransactionViolations filters through the same function: the RHP message, the LHN brick road and Fix badge, the Inbox To-dos count, and the Search red row.

    Add a unit test asserting the violation is hidden from the submitter on a SUBMITTED report and still visible to an admin.

    Alternatives considered and reproduction evidence

    Alternatives:

    • Add it to excludedNoticeNamesForLHN — does not work. That list only applies to notice-type violations; this is a hard violation, and it would leave the RHP message and the Search row untouched.
    • Suppress the Fix badge generically for any violation the current user cannot act on — the right long-term shape, but there is no "is this actionable" concept today, so it is a much larger change with wide blast radius.
    • Hide the message entirely post-submit for everyone — loses the explanation the approver needs.

    How it was introduced: #76728 (merged 2025-12-15) added the constant, the workspace rule and the message. It touched no visibility, brick-road or action-badge code, and the PR's own test plan states the only way the violation clears is an admin disabling the rule.

    Note on the message text: the violation is generated server-side; the App only reads it. The fix above is entirely client-side, so no cross-repo change is needed.

    Evidence (4)

    Draft expense showing Company card purchases required violation pre-submit

    Draft expense showing Company card purchases required violation pre-submit

    Report still showing the violation after submission (status Outstanding)

    Report still showing the violation after submission (status Outstanding)

    Inbox To-dos tab still listing the submitted report with a Fix action

    Inbox To-dos tab still listing the submitted report with a Fix action

    Clicking Fix opens the same report chat with no resolution UI

    Clicking Fix opens the same report chat with no resolution UI

    💡 Suggested AI code review rule

    This looks like a recurring, mechanically detectable pattern, so it may be worth a coding-standards rule. Proposed for Expensify/App:

    • Rule: CONSISTENCY-19 Give every new violation an explicit visibility rule
    • Condition: when a PR adds a name to CONST.VIOLATIONS without adding a matching branch to shouldShowViolation(), flag it and ask the author to state who should see it and in which report states.
    • Why: unhandled names fall through to return true, so the violation drives the red brick road, the Fix action badge and the Inbox To-dos count for users who cannot resolve it — exactly this issue.
    • Search pattern: diff adds a line matching ^\+\s+[A-Z_]+: ' inside the VIOLATIONS object in src/CONST/index.ts, and src/libs/TransactionUtils/index.ts has no added violationName === CONST.VIOLATIONS.<NEW_NAME> branch.
    • Offending code (❌): shouldShowViolation() fall-through
    • Fix (✅): the shape of the existing receiptNotSmartScanned branch

    If it's worth adding, a maintainer can open it as a draft PR in Expensify/App's coding-standards skill.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/99793) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 28, 2026
  5. melvin-bot commented on Aug 28, 2026

    @melvin-bot

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

  6. melvin-bot commented on Aug 28, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. Eskalifer1 commented on Aug 31, 2026

    @Eskalifer1
    Contributor

    @MelvinBot add some code diffs so i can test reliably

  8. MelvinBot commented on Aug 31, 2026

    @MelvinBot
    Contributor

    Here's the diff for the proposal, plus how I tested it.

    The fix

    One branch in shouldShowViolation(). Every surface (RHP message, LHN brick road + Fix pill, Inbox To-dos, Search row) funnels through it, so this one change covers them all.

    diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts
    --- a/src/libs/TransactionUtils/index.ts
    +++ b/src/libs/TransactionUtils/index.ts
    @@ -2124,6 +2124,12 @@ function shouldShowViolation(
             return isPolicyMember && !isSubmitter && !isReportOpen;
         }
     
    +    if (violationName === CONST.VIOLATIONS.COMPANY_CARD_REQUIRED) {
    +        // Once the report leaves the open state the submitter can no longer resolve this violation from the report, so we stop surfacing
    +        // an unactionable Fix action to them. Everyone else reviewing the report (admins, approvers) still needs to see why it is flagged.
    +        return !isSubmitter || isReportOpen;
    +    }
    +
         if (violationName === CONST.VIOLATIONS.MISSING_ATTENDEES) {
             return isAttendeeTrackingEnabledForPolicy(policy);
         }

    I deliberately did not add an admin/approver carve-out for the submitter. A submitter who also happens to be the workspace admin still can't clear it from the report — they clear it in workspace rules — so keeping the unactionable Fix pill for them would just reproduce the bug in the most common test setup (one account owning the workspace).

    Unit tests (tests/unit/TransactionUtilsTest.ts, inside the existing describe('shouldShowViolation'))
    @@ describe('shouldShowViolation', () => {
                 expect(TransactionUtils.shouldShowViolation(iouReport, policy, CONST.VIOLATIONS.OVER_AUTO_APPROVAL_LIMIT, CURRENT_USER_EMAIL, CURRENT_USER_ID)).toBe(true);
             });
    +
    +        it('should return true for company card required violation when the report is still open', () => {
    +            const iouReport: Report = {
    +                ...createRandomReport(0, undefined),
    +                type: CONST.REPORT.TYPE.EXPENSE,
    +                statusNum: CONST.REPORT.STATUS_NUM.OPEN,
    +                stateNum: CONST.REPORT.STATE_NUM.OPEN,
    +                ownerAccountID: CURRENT_USER_ID,
    +                managerID: SECOND_USER_ID,
    +            };
    +
    +            const policy: Policy = {
    +                ...createRandomPolicy(0, CONST.POLICY.TYPE.CORPORATE),
    +                role: CONST.POLICY.ROLE.USER,
    +            };
    +
    +            expect(TransactionUtils.shouldShowViolation(iouReport, policy, CONST.VIOLATIONS.COMPANY_CARD_REQUIRED, CURRENT_USER_EMAIL, CURRENT_USER_ID)).toBe(true);
    +        });
    +
    +        it('should return false for company card required violation when the submitter has already submitted the report', () => {
    +            const iouReport: Report = {
    +                ...createRandomReport(0, undefined),
    +                type: CONST.REPORT.TYPE.EXPENSE,
    +                statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
    +                stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
    +                ownerAccountID: CURRENT_USER_ID,
    +                managerID: SECOND_USER_ID,
    +            };
    +
    +            const policy: Policy = {
    +                ...createRandomPolicy(0, CONST.POLICY.TYPE.CORPORATE),
    +                role: CONST.POLICY.ROLE.USER,
    +            };
    +
    +            expect(TransactionUtils.shouldShowViolation(iouReport, policy, CONST.VIOLATIONS.COMPANY_CARD_REQUIRED, CURRENT_USER_EMAIL, CURRENT_USER_ID)).toBe(false);
    +        });
    +
    +        it('should return true for company card required violation on a submitted report for the approver', () => {
    +            const iouReport: Report = {
    +                ...createRandomReport(0, undefined),
    +                type: CONST.REPORT.TYPE.EXPENSE,
    +                statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
    +                stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
    +                ownerAccountID: SECOND_USER_ID,
    +                managerID: CURRENT_USER_ID,
    +            };
    +
    +            const policy: Policy = {
    +                ...createRandomPolicy(0, CONST.POLICY.TYPE.CORPORATE),
    +                role: CONST.POLICY.ROLE.ADMIN,
    +            };
    +
    +            expect(TransactionUtils.shouldShowViolation(iouReport, policy, CONST.VIOLATIONS.COMPANY_CARD_REQUIRED, CURRENT_USER_EMAIL, CURRENT_USER_ID)).toBe(true);
    +        });
         });

    npm test -- tests/unit/TransactionUtilsTest.ts -t 'shouldShowViolation' → 7 passed. eslint on both files → 0 errors.

    How to test it

    Everything works with a single account:

    1. Create a workspace and upgrade its Plan type to Control (Workspace > Overview > Plan type).
    2. Enable More features > Rules, then turn on Workspace > Rules > Expenses > Require company cards for all purchases.
    3. Submit a manual cash expense on that workspace.

    Before the patch the violation, RBR, Fix pill and To-do stay after step 3. After the patch they clear on submit.

    Two gotchas that cost me time — the expense also picks up an unrelated Missing category violation, which keeps the RBR and Fix pill alive on its own, so set a category before judging steps 3–4; and if you'd rather skip the Control upgrade, you can inject the violation from the dev console instead:

    Onyx.merge('transactionViolations_<transactionID>', [{type: 'violation', name: 'companyCardRequired'}])

    Result on the patched build (web, dev NewDot)

    Pass — the violation shows before submit and clears from all surfaces after submit.

    Step Status Observation
    Before submitting, expense details show red "Company card purchases required" violation pass Draft €25.00 "Test Merchant" cash expense showed the red message before Submit was pressed.
    After submitting, message is gone from expense details pass Report went to Outstanding and the company-card message was gone.
    After submitting, no RBR dot and no orange Fix pill in LHN pass LHN row showed a green Approve pill, no red dot, no Fix pill (after setting the category to clear the unrelated violation).
    After submitting, Inbox > To-dos does not list the report with a Fix action pass To-dos listed the report with an Approve action pill, not Fix.
    Evidence (4)

    Expense details showing red Company card purchases required violation before submit

    Expense details showing red Company card purchases required violation before submit

    Expense details after submit, company-card violation message gone

    Expense details after submit, company-card violation message gone

    LHN showing green Approve pill, no RBR dot, no Fix pill

    LHN showing green Approve pill, no RBR dot, no Fix pill

    Inbox To-dos listing the report with Approve action, not Fix

    Inbox To-dos listing the report with Approve action, not Fix

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/99793#issuecomment-5457988432) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  9. Eskalifer1 commented on Aug 31, 2026

    @Eskalifer1
    Contributor

    I was able to reproduce the bug, and yes, I think Melvin’s proposal is correct(at least the mechanism)

    The only thing we need is clear guidance on when exactly this error should be displayed, as I’m not sure that !isSubmitter || isReportOpen is the correct condition. I think an internal developer could help clarify the expected behavior here.

    🎀 👀 🎀 C+ reviewed

  10. melvin-bot commented on Aug 31, 2026

    @melvin-bot

    Triggered auto assignment to @chuckdries, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  11. 32 remaining items

  12. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Sep 14, 2026
  13. melvin-bot commented on Sep 14, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  14. melvin-bot commented on Sep 14, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  15. mallenexpensify commented on Sep 16, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @Eskalifer1 paid $250 via Upwork

  16. Eskalifer1 commented on Sep 16, 2026

    @Eskalifer1
    Contributor

    Hi @mallenexpensify, i'm still getting paid via Upwork

  17. mallenexpensify commented on Sep 17, 2026

    @mallenexpensify
    Contributor

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

  18. Eskalifer1 commented on Sep 18, 2026

    @Eskalifer1
    Contributor

    Hi @mallenexpensify, i have accepted, thank you!

  19. mallenexpensify commented on Sep 18, 2026

    @mallenexpensify
    Contributor

    @Eskalifer1 paid, summary updated above. Thx.

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 contributorNeeds ReproductionReproducible steps needed

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions