Skip to content

[$250] Expense - Report can be selected on confirm page when expense cannot be added #77661

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.2.78-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: Exp #75792
Email or phone of affected tester (no customers): isjdsoijsojnsiojisndj@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Critical User Impact
Device used: Mac 26.1 / Chrome
App Component: Money Requests

Action Performed:

  1. Go to staging.new.expensify.com
  2. Create a workspace.
  3. Go to workspace chat.
  4. Create an expense in workspace chat.
  5. Click Submit on the expense preview.
  6. Open the report and rename it (to easily identify later).
  7. Go back to workspace chat and create an empty report.
  8. Go to workspace settings > Workflows.
  9. Disable Add approvals and Make or track payments.
  10. Change Submission frequency to Instantly.
  11. Go back to workspace chat.
  12. Click + > Create expense > Manual.
  13. Enter amount > Next.
  14. On confirm page, click Report and select the first report from Step 6.
  15. Click Create expense.

Expected Result:

In Step 14, user should not be able to select the outstanding report from Step 6 because app does not allow user to add expense to it after changing submission frequency from Manually to Instantly.

Actual Result:

In Step 14, user can select the outstanding report from Step 6.
In Step 15, after creating the expense, app opens the selected report in Step 14, but the expense is created in a new report.

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

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022001509799870274929
  • Upwork Job ID: 2001509799870274929
  • Last Price Increase: 2026-01-08
  • Automatic offers:
    • mkzie2 | Contributor | 110086563
Issue OwnerCurrent Issue Owner: @MariaHCD

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 15, 2025
  2. melvin-bot commented on Dec 15, 2025

    @melvin-bot

    Triggered auto assignment to @strepanier03 (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. etCoderDysto commented on Dec 15, 2025

    @etCoderDysto
    Contributor

    Proposal

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

    Report can be selected on confirm page when expense cannot be added

    What is the root cause of that problem?

    Inside getOutstandingReportsForUser, we are not checking if the policy is has isInstantSubmitEnabled, isSubmitAndClose and payments are disabled configuration before we return all outstanding reports

    App/src/libs/ReportUtils.ts

    Lines 11417 to 11427 in 4456dcd

    function getOutstandingReportsForUser(
    policyID: string | undefined,
    reportOwnerAccountID: number | undefined,
    reports: OnyxCollection<Report> = allReports,
    reportNameValuePairs: OnyxCollection<ReportNameValuePairs> = allReportNameValuePair,
    allowSubmitted = true,
    ): Array<OnyxEntry<Report>> {
    if (!reports) {
    return [];
    }
    return Object.values(reports).filter(

    Then availableOutstandingReports.length > 1 will be true and we make report field editable

    const shouldReportBeEditable = (isFromGlobalCreate ? shouldReportBeEditableFromFAB : availableOutstandingReports.length > 1) && !isMoneyRequestReport(reportID, allReports);

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

    We should return empty array if isInstantSubmitEnabled, isSubmitAndClose and payments are disabled

    const policy = allPolicies[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`];
        const isInstantSubmitEnabledLocal = isInstantSubmitEnabled(policy);
        const isSubmitAndCloseLocal = isSubmitAndClose(policy);
        const arePaymentsDisabled = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;
        if (isInstantSubmitEnabledLocal && isSubmitAndCloseLocal && arePaymentsDisabled) {
            return [];
        }
        return Object.values(reports).filter(
            (report) =>
    

    What alternative solutions did you explore? (Optional)

    Inside MoneyRequestConfirmationListFooter, we can filter availableOutstandingReports to return availableOutstandingReports when the workflow configuration mentioned above is not true and use the filteredOutStandingReports instead of availableOutstandingReports here

    const filteredOutStandingReports = useMemo(()=> {
            const isInstantSubmitEnabledLocal = isInstantSubmitEnabled(policy);
                const isSubmitAndCloseLocal = isSubmitAndClose(policy);
                const arePaymentsDisabled = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;
                if (isInstantSubmitEnabledLocal && isSubmitAndCloseLocal && arePaymentsDisabled) {
                    return [];
                }
                return availableOutstandingReports;
    
    
        },[availableOutstandingReports, policy])
    
     const shouldReportBeEditable = (isFromGlobalCreate ? shouldReportBeEditableFromFAB : filteredOutStandingReports.length > 1) && !isMoneyRequestReport(reportID, allReports); 
    

    Note: we can do similar changes in IOURequestEditReportCommon if needed

  4. nkdengineer commented on Dec 15, 2025

    @nkdengineer
    Contributor

    Proposal

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

    In Step 14, user can select the outstanding report from Step 6.
    In Step 15, after creating the expense, app opens the selected report in Step 14, but the expense is created in a new report.

    What is the root cause of that problem?

    It looks like shouldAllowSubmittedReport condition is incorrect; it's always true for instant submit.

    const shouldAllowSubmittedReport = allowSubmitted || isInstantSubmitEnabled(policy) || isProcessingReport(activeReport);

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

    In Step 14, user should not be able to select the outstanding report from Step 6 because app does not allow user to add expense to it after changing submission frequency from Manually to Instantly.

    Based on the expected, we should only allow the submitted report if the submission frequency is not instant. We can also check if the payment is disabled and the policy is submit and close. It can disccus in the PR to match with the backend logic.

    const shouldAllowSubmittedReport = allowSubmitted || !isInstantSubmitEnabled(policy) || isProcessingReport(activeReport);
    

    const shouldAllowSubmittedReport = allowSubmitted || isInstantSubmitEnabled(policy) || isProcessingReport(activeReport);

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  5. ShridharGoel commented on Dec 15, 2025

    @ShridharGoel
    Contributor

    Proposal

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

    On the expense confirmation page, a user can still select a submitted expense report after switching the workspace to Instant submit + Submit & Close with payments disabled. The app then opens that submitted report, but the expense is placed in a new report instead of the one the user picked.

    What is the root cause of that problem?

    • The outstanding-report selector passes allowSubmitted=false, but isReportOutstanding still treats submitted reports as valid whenever the policy has Instant submit enabled, so those reports stay selectable even though they cannot accept more expenses. See the logic in shouldAllowSubmittedReport, which ignores the caller’s allowSubmitted flag when auto-submit is instant.

      App/src/libs/ReportUtils.ts

      Lines 11393 to 11407 in 8cd91dc

      const currentRoute = navigationRef.getCurrentRoute();
      const params = currentRoute?.params as MoneyRequestNavigatorParamList[typeof SCREENS.MONEY_REQUEST.STEP_CONFIRMATION] | ReportsSplitNavigatorParamList[typeof SCREENS.REPORT];
      const activeReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${params?.reportID}`];
      const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`];
      const reportNameValuePair = reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReport.reportID}`];
      const shouldAllowSubmittedReport = allowSubmitted || isInstantSubmitEnabled(policy) || isProcessingReport(activeReport);
      return (
      isExpenseReport(iouReport) &&
      iouReport?.stateNum !== undefined &&
      iouReport?.statusNum !== undefined &&
      iouReport?.policyID === policyID &&
      (shouldAllowSubmittedReport ? iouReport?.stateNum <= CONST.REPORT.STATE_NUM.SUBMITTED : iouReport?.stateNum < CONST.REPORT.STATE_NUM.SUBMITTED) &&
      (shouldAllowSubmittedReport ? iouReport?.statusNum <= CONST.REPORT.STATE_NUM.SUBMITTED : iouReport?.statusNum < CONST.REPORT.STATE_NUM.SUBMITTED) &&
      !hasForwardedAction(iouReport.reportID) &&
      !isArchivedReport(reportNameValuePair)

    • MoneyRequestConfirmationListFooter relies on getOutstandingReportsForUser(..., allowSubmitted=false) to hide submitted reports, but because the helper above still includes them, the UI exposes destinations the backend will reject.

      const transactionReport = transaction?.reportID ? Object.values(allReports ?? {}).find((report) => report?.reportID === transaction.reportID) : undefined;
      const policyID = selectedParticipants?.at(0)?.policyID;
      const selectedPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`];
      const shouldUseTransactionReport = (!!transactionReport && isReportOutstanding(transactionReport, policyID, undefined, false)) || isUnreported;
      const ownerAccountID = selectedParticipants?.at(0)?.ownerAccountID;
      const availableOutstandingReports = useMemo(() => {
      return getOutstandingReportsForUser(policyID, ownerAccountID, outstandingReportsByPolicyID?.[policyID ?? CONST.DEFAULT_NUMBER_ID] ?? {}, reportNameValuePairs, false).sort((a, b) =>
      localeCompare(a?.reportName?.toLowerCase() ?? '', b?.reportName?.toLowerCase() ?? ''),
      );
      }, [policyID, ownerAccountID, outstandingReportsByPolicyID, reportNameValuePairs, localeCompare]);
      const iouReportID = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.iouReportID;
      const outstandingReportID = isPolicyExpenseChat ? (iouReportID ?? availableOutstandingReports.at(0)?.reportID) : reportID;
      const [selectedReportID, selectedReport] = useMemo(() => {
      const reportIDToUse = shouldUseTransactionReport ? transaction?.reportID : outstandingReportID;
      if (!reportIDToUse) {
      // Even if we have no report to use we still need a report id for proper navigation
      return [generateReportID(), undefined];
      }
      const reportToUse = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportIDToUse}`];
      return [reportIDToUse, reportToUse];
      }, [allReports, shouldUseTransactionReport, transaction?.reportID, outstandingReportID]);

    • We also do not filter the list by whether a report can currently accept new transactions (canAddTransaction), so once a submitted report slips through, nothing else blocks it from being selected.

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

    • Make allowSubmitted authoritative: drop the Instant-submit override so submitted reports are excluded whenever callers pass allowSubmitted=false, while still letting in-processing reports stay selectable.
    • Only surface reports that can actually accept new expenses when allowSubmitted is false, reusing canAddTransaction to mirror backend rules (instant + submit & close + payments disabled, non-reimbursable-only, etc.).

    Code changes:

    // src/libs/ReportUtils.ts
    function isReportOutstanding(
        iouReport: OnyxInputOrEntry<Report>,
        policyID: string | undefined,
        reportNameValuePairs: OnyxCollection<ReportNameValuePairs> = allReportNameValuePair,
        allowSubmitted = true,
    ): boolean {
        ...
        const shouldAllowSubmittedReport = allowSubmitted || isProcessingReport(activeReport);
        const meetsSubmittedThreshold =
            shouldAllowSubmittedReport
                ? iouReport.stateNum <= CONST.REPORT.STATE_NUM.SUBMITTED && iouReport.statusNum <= CONST.REPORT.STATUS_NUM.SUBMITTED
                : iouReport.stateNum < CONST.REPORT.STATE_NUM.SUBMITTED && iouReport.statusNum < CONST.REPORT.STATUS_NUM.SUBMITTED;
        const canReceiveTransactions = allowSubmitted || canAddTransaction(iouReport);
    
        return (
            isExpenseReport(iouReport) &&
            iouReport?.policyID === policyID &&
            meetsSubmittedThreshold &&
            !hasForwardedAction(iouReport.reportID) &&
            !isArchivedReport(reportNameValuePair) &&
            canReceiveTransactions
        );
    }
    
    function getOutstandingReportsForUser(
        policyID: string | undefined,
        reportOwnerAccountID: number | undefined,
        reports: OnyxCollection<Report> = allReports,
        reportNameValuePairs: OnyxCollection<ReportNameValuePairs> = allReportNameValuePair,
        allowSubmitted = true,
    ): Array<OnyxEntry<Report>> {
        if (!reports) {
            return [];
        }
    
        return Object.values(reports).filter(
            (report) =>
                report?.pendingFields?.preview !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
                isReportOutstanding(report, policyID, reportNameValuePairs, allowSubmitted) &&
                report?.ownerAccountID === reportOwnerAccountID &&
                (allowSubmitted || canAddTransaction(report)),
        );
    }
  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Dec 18, 2025
  7. changed the title [-]Expense - Report can be selected on confirm page when expense cannot be added[/-] [+][$250] Expense - Report can be selected on confirm page when expense cannot be added[/+] on Dec 18, 2025
  8. melvin-bot commented on Dec 18, 2025

    @melvin-bot
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 18, 2025
  10. melvin-bot commented on Dec 18, 2025

    @melvin-bot

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

  11. 49 remaining items

  12. mkzie2 commented on Jan 14, 2026

    @mkzie2
    Contributor

    @dukenv0307 The PR is ready for review.

  13. dukenv0307 commented on Feb 13, 2026

    @dukenv0307
    Contributor

    @strepanier03, please remove the Reviewing label and bump to Daily as payment is due

  14. melvin-bot commented on Feb 13, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @strepanier03, @MariaHCD, @dukenv0307, @mkzie2 eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  15. dukenv0307 commented on Mar 2, 2026

    @dukenv0307
    Contributor

    @strepanier03 kindly bump

  16. dukenv0307 commented on Mar 6, 2026

    @dukenv0307
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/62592/changes#r2893791301

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal Template
    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    Test:

    1. Create a workspace.
    2. Go to workspace chat.
    3. Create an expense and submit it.
    4. Go back to workspace chat and create an empty report.
    5. Go to workspace settings > Workflows.
    6. Disable Add approvals and Make or track payments.
    7. Change Submission frequency to Instantly.
    8. Go back to workspace chat.
    9. Click + > Create expense > Manual.
      10 .Enter amount > Next.
    10. On confirm page, verify that: We can't select the expense report created in step 3.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-2a8b-a3b8-51a0-70374af1c384
  17. strepanier03 commented on Mar 6, 2026

    @strepanier03
    Contributor

    Payment summary

    For: #79583

  18. quinthar commented on Mar 11, 2026

    @quinthar
    Contributor

    Approved $250 to @dukenv0307

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