Skip to content

Expense - "Missing Category" error message appears after bulk editing unreported expenses. #84683

Closed

Description

@jponikarchuk

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.3.34.0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #82948
Email or phone of affected tester (no customers): ibellicotest+2250@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome
App Component: Money Requests

Action Performed:

Prerequisite: Account has Self DM.

  1. Open the Expensify app.
  2. Navigate to Self DM.
  3. Create two manual expenses without category.
  4. Navigate to "Reports" > "Expenses"
  5. Select both expenses, tap on dropdown menu and select "Edit Multiple"
  6. Edit some of the available fields (For example: Merchant and description), but leave "Category" field unedited.
  7. Save the editions.
  8. Note that a "Missing Category" error, appears on expenses after the editions are applied.

Expected Result:

"Missing Category" error shouldn´t be visible on unreported expenses.

Actual Result:

"Missing Category" error, appears on unreported expenses after editing other fields and leaving "Category" unedited.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCash
    Bug
    on Mar 10, 2026
  2. melvin-bot commented on Mar 10, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #82948

  3. melvin-bot commented on Mar 10, 2026

    @melvin-bot

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

  4. melvin-bot commented on Mar 10, 2026

    @melvin-bot

    Triggered auto assignment to @trjExpensify (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.

  5. github-actions commented on Mar 10, 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. OSBotify commented on Mar 10, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #82948 - "Reapply "Feat: bulk edit multiple"" by @pasyukevich (High confidence)
    Related Issues: None

    Recommendation: REVERT

    PR #82948 introduces bulk edit functionality but has a critical bug in how it handles unreported expenses from Self DMs. The PR should be reverted to unblock the deploy.

    Labels: No label changes needed - keeping DeployBlockerCash as this is a frontend bug affecting the App

    Detailed Analysis

    Evidence

    The issue occurs when bulk editing unreported expenses that were created in a Self DM:

    1. User creates expenses in Self DM without category
    2. Views them in Reports > Expenses (unreported expenses view)
    3. Bulk edits other fields (merchant, description) but leaves category unchanged
    4. "Missing Category" error incorrectly appears

    PR #82948 introduced the updateMultipleMoneyRequests function which performs bulk edits. The issue is reproducible only in staging where this PR is deployed, and the issue description explicitly links to this PR.

    Verification

    I verified that PR #82948 modifies src/libs/actions/IOU/index.ts, which contains the bulk edit logic. The changes include:

    • New updateMultipleMoneyRequests function (line 13979+)
    • New violation calculation logic for bulk edits

    Root Cause

    The bug is in /home/runner/_work/App/App/src/libs/actions/IOU/index.ts at line 14156:

    ViolationsUtils.getViolationsOnyxData(
        updatedTransaction,
        optimisticViolations,
        policy,
        policyTagList,
        policyCategories ?? {},
        hasDependentTags(policy, policyTagList),
        isInvoiceReportReportUtils(iouReport),
        isSelfDM(iouReport),  // <-- LINE 14156: This is the problem
        iouReport,
        isFromExpenseReport,
    )

    The Problem:

    • Unreported expenses have transaction.reportID = "0" (CONST.REPORT.UNREPORTED_REPORT_ID)
    • At line 13997, iouReport = reports?.["report_0"] which is undefined (no report exists with ID "0")
    • isSelfDM(undefined) returns false
    • getViolationsOnyxData in ViolationsUtils.ts (line 385-386) then adds a "missingCategory" violation because:
      • The policy requires categories
      • Category is not set
      • It thinks its NOT a Self DM (because isSelfDM param is false)

    Why This Matters:
    Self DM expenses should NOT show "missing category" violations even if the policy requires categories. The code loses the Self DM context for unreported expenses, incorrectly applying violation rules.

    Technical Details

    The violation logic in /home/runner/_work/App/App/src/libs/Violations/ViolationsUtils.ts (lines 384-387) states:

    // Add missingCategory violation if category is required and not set
    if (!hasMissingCategoryViolation && policyRequiresCategories && !categoryKey && !isSelfDM) {
        newTransactionViolations.push({name: missingCategory, type: CONST.VIOLATION_TYPES.VIOLATION, showInReview: true});
    }

    The !isSelfDM check should prevent this violation for Self DM expenses, but it fails because the Self DM context is lost for unreported expenses.

  7. MelvinBot commented on Mar 10, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When users bulk-edit unreported expenses (e.g., editing only Merchant and Description) but leave the "Category" field untouched, a "Missing Category" error/violation appears on the expenses after saving. This error should not appear on unreported expenses that never had it before.

    What is the root cause of that problem?

    There is an asymmetry between expense creation and bulk edit regarding violation computation for unreported expenses.

    At creation time (src/libs/actions/IOU/index.ts:2629-2631), violation computation is explicitly skipped for unreported expenses:

    if (!policy || !isPaidGroupPolicy(policy) || transaction.reportID === CONST.REPORT.UNREPORTED_REPORT_ID) {
        return onyxData;
    }

    At bulk edit time (src/libs/actions/IOU/index.ts:14136), the UNREPORTED_REPORT_ID guard is missing:

    if (policy) {  // <-- No UNREPORTED_REPORT_ID check!
        ...
        optimisticData.push(
            ViolationsUtils.getViolationsOnyxData(
                updatedTransaction,
                optimisticViolations,
                ...
                isSelfDM(iouReport),  // returns false for unreported expenses
                ...
            ),
        );
    }

    When any field is bulk-edited, ViolationsUtils.getViolationsOnyxData() runs on the full transaction. For unreported expenses without a category, it evaluates (ViolationsUtils.ts:385):

    if (!hasMissingCategoryViolation && policyRequiresCategories && !categoryKey && !isSelfDM) {
        newTransactionViolations.push({name: 'missingCategory', ...});
    }

    All conditions are met because:

    • policyRequiresCategories is true (policy has categories enabled)
    • categoryKey is falsy (expense had no category)
    • isSelfDM is false (because iouReport is undefined for unreported expenses — reports?.[report_0] resolves to undefined)
    • hasMissingCategoryViolation is false (violations were empty since creation skipped them)

    This results in a fresh missingCategory violation being optimistically added even though category was never edited.

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

    Add the UNREPORTED_REPORT_ID guard to the violation computation block in updateMultipleMoneyRequests at src/libs/actions/IOU/index.ts:14136, consistent with the creation-time behavior:

    Change the condition from:

    if (policy) {

    to:

    if (policy && transaction.reportID !== CONST.REPORT.UNREPORTED_REPORT_ID) {

    This ensures unreported expenses skip optimistic violation computation during bulk edit, matching the intentional behavior established at creation time.

    What alternative solutions did you explore? (Optional)

    An alternative would be to fix the isSelfDM check for unreported expenses by looking up the Self DM report directly rather than deriving it from iouReport (which is undefined when reportID is '0'). However, this would change the existing design decision that unreported expenses should not compute violations at all, so the guard approach is more consistent.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  8. added
    Reviewing
    on Mar 10, 2026
  9. IuliiaHerets commented on Mar 10, 2026

    @IuliiaHerets

    Chrome / 9.3.34-1 and Samsung A52 / Android 14
    No Edit Multiple option

    Screen.Recording.2026-03-10.at.19.07.13.mp4
    bulk.select.mp4
  10. removed
    DeployBlockerCash
    on Mar 10, 2026
  11. marcaaron commented on Apr 3, 2026

    @marcaaron
    Contributor

    Fixed in #84756

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

Metadata

Metadata

Labels

BugEngineeringHourlyReviewing

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions