Skip to content

Reports - Violation appears twice #79007

Closed

Description

@mitarachim

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: 9.2.95-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-2697/folder/13176707/41236879/1110522157?q=violation&issue_type=jira
Email or phone of affected tester (no customers): sdjoisjnodisjoijdosi@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.1 / Chrome
App Component: Money Requests

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create an expense without category and hold the expense.
  4. Go to Reports > Expenses.

Expected Result:

Missing category and hold violation will appear one time.

Actual Result:

Missing category and hold violation appears twice.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7042851_1767794736223.5.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on Jan 7, 2026
  2. melvin-bot commented on Jan 7, 2026

    @melvin-bot

    Triggered auto assignment to @sakluger (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. melvin-bot commented on Jan 7, 2026

    @melvin-bot

    Triggered auto assignment to @marcaaron (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  4. melvin-bot commented on Jan 7, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on Jan 7, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. twinkle-react commented on Jan 7, 2026

    @twinkle-react

    Proposal

    Please re-state the problem that we are trying to solve in this issue.
    Reports show the “Missing category” and “Hold” violation twice for the same expense instead of only once.

    What is the root cause of that problem?
    The code that adds the HOLD violation does not check if a HOLD violation already exists for the transaction. As a result, every time the expense is processed, a new violation is appended, causing duplicates in Onyx and the UI.

    What changes do you think we should make in order to solve the problem?
    Add a check before pushing a new HOLD violation to the transactionViolations array. Only add the violation if it does not already exist.

    File: src/libs/actions/IOU/index.ts

    // ... existing code ...
    const newViolation = {
        name: CONST.VIOLATIONS.HOLD,
        type: CONST.VIOLATION_TYPES.VIOLATION,
        showInReview: true,
    };
    
    const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? [];
    
    // Prevent duplicate HOLD violations
    const hasHoldViolation = transactionViolations.some(
        (violation) => violation.name === CONST.VIOLATIONS.HOLD
    );
    
    const updatedViolations = hasHoldViolation
        ? transactionViolations
        : [...transactionViolations, newViolation];
    
    // ... existing code ...

    Description of change:

    • Added hasHoldViolation check to ensure a HOLD violation is only added once per transaction.
    • Prevents duplicate entries at the source before writing to Onyx.

    Justification:

    • src/libs/actions/IOU/index.ts owns the logic for creating and storing transaction violations.
    • Fixing here directly addresses the duplicate violation issue at the source.

    Final Enforcement Line:
    The fix narrows the existing write to Onyx by only adding a HOLD violation if it does not already exist.

    What alternative solutions did you explore? (Optional)
    N/A

  7. arosiclair commented on Jan 7, 2026

    @arosiclair
    Contributor

    This is no longer reproducible in v9.2.95-2 (Note: I had to enable Workspaces > {workspace} > Categories > Settings > Members must tag or categorize all expenses).

    I think reverting #78315 probably fixed this cc @ikevin127 @jayeshmangwani @JS00001

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DeployBlockerIndicates it should block deploying the APIEngineeringHourlyKSv2ReviewingHas a PR in review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions