Skip to content

[Due for payment 2026-01-12] [$250] Expense - "Submit" changes to "Approve" on preview when online after partially approve offline #76780

Closed

Description

@vincdargento

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.72-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: #74541
Email or phone of affected tester (no customers): ibellicotest+2154@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 / Android 12 / Chrome (mWeb / Hybrid app) - Windows 11 / Chrome
App Component: Money Requests

Action Performed:

Prerequisite: Account has at least one workspace.

  1. Open the Expensify app.
  2. Open any workspace chat.
  3. Create two manual expenses.
  4. Open the report.
  5. Long tap and select one of the expenses.
  6. Tap on dropdown menu and select "Hold"
  7. Enter any reason and hold the expense.
  8. Return to chat.
  9. Tap on "Submit" on report preview.
  10. Turn off internet connection.
  11. Tap on "Approve"
  12. Approve only the unheld amount.
  13. Note that held expense is moved to a new report and shows a "Submit" button on preview.
  14. Turn on internet connection.
  15. Note that "Submit" button changes to "Approve".

Expected Result:

After partially approving report offline, preview of held expense should automatically display an "Approve" button.

Actual Result:

After partially approving a report while offline, preview of held expense shows a "Submit" button, that changes to "Approve" when back online.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021996731646343908370
  • Upwork Job ID: 1996731646343908370
  • Last Price Increase: 2025-12-05
  • Automatic offers:
    • situchan | Reviewer | 109722754
Issue OwnerCurrent Issue Owner: @kadiealexander

Activity

  1. added
    Daily
    Bug
    on Dec 4, 2025
  2. melvin-bot commented on Dec 4, 2025

    @melvin-bot

    Triggered auto assignment to @jliexpensify (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. nyomanjyotisa commented on Dec 4, 2025

    @nyomanjyotisa
    Member

    Proposal

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

    Expense - "Submit" changes to "Approve" on preview when online after partially approve offline

    What is the root cause of that problem?

    When partially approving a report offline (approving only the unheld amount), a new expense report is created for the held transactions using getReportFromHoldRequestsOnyxData. This function then calls buildOptimisticExpenseReport which determines the report stateNum and statusNum

    const {stateNum, statusNum} = getExpenseReportStateAndStatus(policy);

    The issue is that getExpenseReportStateAndStatus returns OPEN/OPEN when instant submit is not enabled

    App/src/libs/ReportUtils.ts

    Lines 6797 to 6800 in 666a8b0

    return {
    stateNum: CONST.REPORT.STATE_NUM.OPEN,
    statusNum: CONST.REPORT.STATUS_NUM.OPEN,
    };

    However, the held transactions were already part of a submitted (processing) report. When they're moved to a new report during partial approval, that new report should maintain the SUBMITTED/SUBMITTED (Processing) state so that the "Approve" button shows, not "Submit"

    canApprove function requires the report to be in processing state (isProcessingReport) to show "Approve"

    function canApprove(report: Report, currentUserAccountID: number, policy?: Policy, transactions?: Transaction[]) {
    const isExpense = isExpenseReport(report);
    const isProcessing = isProcessingReport(report);
    const isApprovalEnabled = policy?.approvalMode && policy.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL;
    const managerID = report.managerID ?? CONST.DEFAULT_NUMBER_ID;
    const isCurrentUserManager = managerID === currentUserAccountID;
    const reportTransactions = transactions ?? getReportTransactions(report?.reportID);
    const isAnyReceiptBeingScanned = transactions?.some((transaction) => isScanning(transaction));
    if (isAnyReceiptBeingScanned) {
    return false;
    }
    if (reportTransactions.length > 0 && reportTransactions.every((transaction) => isPending(transaction))) {
    return false;
    }
    const isPreventSelfApprovalEnabled = policy?.preventSelfApproval;
    const isReportSubmitter = isCurrentUserSubmitter(report);
    if (isPreventSelfApprovalEnabled && isReportSubmitter) {
    return false;
    }
    return isExpense && isProcessing && !!isApprovalEnabled && reportTransactions.length > 0 && isCurrentUserManager;

    And isProcessingReport checks for stateNum === SUBMITTED && statusNum === SUBMITTED:

    App/src/libs/ReportUtils.ts

    Lines 1948 to 1950 in 666a8b0

    function isProcessingReport(report: OnyxEntry<Report>): boolean {
    return report?.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && report?.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED;
    }

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

    In getReportFromHoldRequestsOnyxData, when adding the optimistic expense report for held transactions, we should override the stateNum and statusNum to SUBMITTED to ensure the report is in processing state and shows "Approve" button

            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticExpenseReport.reportID}`,
                value: {
                    ...optimisticExpenseReport,
                    unheldTotal: 0,
                    unheldNonReimbursableTotal: 0,
                    stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
                    statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
                },
            },

    App/src/libs/actions/IOU.ts

    Lines 9965 to 9973 in 666a8b0

    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticExpenseReport.reportID}`,
    value: {
    ...optimisticExpenseReport,
    unheldTotal: 0,
    unheldNonReimbursableTotal: 0,
    },
    },

    or preserve the original report's state

            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticExpenseReport.reportID}`,
                value: {
                    ...optimisticExpenseReport,
                    unheldTotal: 0,
                    unheldNonReimbursableTotal: 0,
                    stateNum: iouReport?.stateNum ?? CONST.REPORT.STATE_NUM.SUBMITTED,
                    statusNum: iouReport?.statusNum ?? CONST.REPORT.STATUS_NUM.SUBMITTED,
                },
            },

    What alternative solutions did you explore? (Optional)

    None

  4. added
    External
    on Dec 5, 2025
  5. changed the title [-]Expense - "Submit" changes to "Approve" on preview when online after partially approve offline[/-] [+][$250] Expense - "Submit" changes to "Approve" on preview when online after partially approve offline[/+] on Dec 5, 2025
  6. melvin-bot commented on Dec 5, 2025

    @melvin-bot
  7. added
    Help Wanted
    on Dec 5, 2025
  8. melvin-bot commented on Dec 5, 2025

    @melvin-bot

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

  9. nkdengineer commented on Dec 5, 2025

    @nkdengineer
    Contributor

    Proposal

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

    After partially approving a report while offline, preview of held expense shows a "Submit" button, that changes to "Approve" when back online.

    What is the root cause of that problem?

    The new report is created with the default stateNum and statusNum. It doesn't check the current status of the iouReport.

    const {stateNum, statusNum} = getExpenseReportStateAndStatus(policy);

    App/src/libs/actions/IOU.ts

    Lines 9873 to 9875 in 666a8b0

    const optimisticExpenseReport = isPolicyExpenseChat
    ? buildOptimisticExpenseReport(
    chatReport.reportID,

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

    The behavior from the backend is

    • Approve the report partially, the new report is a processing report
    • Pay the report partially, the new report is a draft report
      const {stateNum, statusNum} = getExpenseReportStateAndStatus(policy);

      App/src/libs/actions/IOU.ts

      Lines 9873 to 9875 in 666a8b0

      const optimisticExpenseReport = isPolicyExpenseChat
      ? buildOptimisticExpenseReport(
      chatReport.reportID,

      So we should do the same with the optimistic data, only update the new report as a processing report if the current report is being approved.
    const policy = getPolicy(iouReport?.policyID);
    const isApprovalEnabled = policy ? policy.approvalMode && policy.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL : false;
    value: {
    ...optimisticExpenseReport,
    unheldTotal: 0,
    unheldNonReimbursableTotal: 0,
    ...(isProcessingReport(iouReport) && isApprovalEnabled ? {
    stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
    statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
    } : {}),
    },
    

    App/src/libs/actions/IOU.ts

    Lines 9965 to 9973 in 666a8b0

    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticExpenseReport.reportID}`,
    value: {
    ...optimisticExpenseReport,
    unheldTotal: 0,
    unheldNonReimbursableTotal: 0,
    },
    },

    What alternative solutions did you explore? (Optional)

    We can pass newStateNum and newStatusNum param to getReportFromHoldRequestsOnyxData function when approving/paying partially.
    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.

  10. github-actions commented on Dec 5, 2025

    @github-actions
    Contributor

    ⚠️ @nkdengineer Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  11. situchan commented on Dec 5, 2025

    @situchan
    Contributor
               stateNum: iouReport?.stateNum ?? CONST.REPORT.STATE_NUM.SUBMITTED,
               statusNum: iouReport?.statusNum ?? CONST.REPORT.STATUS_NUM.SUBMITTED,
    

    @nkdengineer have you found any issue with this solution?

    I don't see the case of "Pay the report partially, the new report is a draft report"

  12. nkdengineer commented on Dec 5, 2025

    @nkdengineer
    Contributor

    @situchan You can try these steps

    1. Disable the Approval, enable payment.
    2. Create two expenses, hold one of them
    3. Submit the report
    4. Then you can see the pay button
    5. Pay partially
  13. 22 remaining items

  14. removed
    Reviewing
    on Jan 5, 2026
  15. melvin-bot commented on Jan 5, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  16. melvin-bot commented on Jan 5, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.92-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-01-12. 🎊

    For reference, here are some details about the assignees on this issue:

  17. melvin-bot commented on Jan 5, 2026

    @melvin-bot

    @situchan @jliexpensify The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  18. jliexpensify commented on Jan 6, 2026

    @jliexpensify
    Contributor

    Assigning @kadiealexander to help with payments/checklist while I'm OOO

    Payment Summary

  19. situchan commented on Jan 6, 2026

    @situchan
    Contributor

    I already accepted this offer and requested payment on upwork.

  20. added
    Daily
    and removed
    Weekly
    on Jan 11, 2026
  21. kadiealexander commented on Jan 11, 2026

    @kadiealexander
    Contributor

    @situchan could you please complete the checklist?

  22. situchan commented on Jan 12, 2026

    @situchan
    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/42573/changes#r2680759044

    • [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: N/A

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

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

      Link to issue: https://github.com/Expensify/Expensify/issues/587743

    Regression Test Proposal

    Test:

    Case 1: Approve partial

    1. Open any workspace chat.
    2. Create two manual expenses.
    3. Open the report.
    4. Hold an expense
    5. Submit the report
    6. Turn off internet connection.
    7. Tap on "Approve"
    8. Approve only the unheld amount.
    9. Verify that the Approve button is shown for the new report preview

    Case 2: Pay partial
    Precondition: Approval is disabled, payment is enabled

    1. Open workspace chat.
    2. Create two manual expenses.
    3. Open the report.
    4. Hold an expense
    5. Submit the report
    6. Turn off internet connection.
    7. Tap on "Pay"
    8. Pay only the unheld amount.
    9. Verify that the Submit button is shown for the new report preview

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-85e1-af16-867b-e22f42062ad4
  23. twisterdotcom commented on Jan 12, 2026

    @twisterdotcom
    Contributor

    @nkdengineer has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-4ef7-a88c-8bbe-cf1949b3f3f4
  24. m-natarajan commented on Jun 18, 2026

    @m-natarajan

    @situchan This is regarding the regression test proposal.
    Is the submit flow for a report with an expense on hold changed?
    Pay only the unheld amount not displayed and new report created for the held expense when report is submitted

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions