Skip to content

[$250] Expense - Unable to remove expense from report after changing approver #72731

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.32-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: #70283
Email or phone of affected tester (no customers): sjidnojoidjiojdsd@gmail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.5 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Workspace has at least two members.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create an expense in workspace chat.
  4. Open expense report.
  5. Click Submit.
  6. Click More > Change approver.
  7. Select Add approver > Change approver.
  8. Upgrade workspace if prompted > Change approver.
  9. Select a user > Save.
  10. Click Report.
  11. Click Remove from report.

Expected Result:

The expense will be removed successfully.

Actual Result:

The removed expense reappears in the report.

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

Bug6976120_1760569845119.Screen_Recording_2025-10-16_at_07.06.20.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021978659860408853229
  • Upwork Job ID: 1978659860408853229
  • Last Price Increase: 2025-10-16
  • Automatic offers:
    • FitseTLT | Reviewer | 109864269
Issue OwnerCurrent Issue Owner: @AndrewGable

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 16, 2025
  2. melvin-bot commented on Oct 16, 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. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 16, 2025
  4. melvin-bot commented on Oct 16, 2025

    @melvin-bot
  5. changed the title [-]Expense - Unable to remove expense from report after changing approver[/-] [+][$250] Expense - Unable to remove expense from report after changing approver[/+] on Oct 16, 2025
  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 16, 2025
  7. melvin-bot commented on Oct 16, 2025

    @melvin-bot

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

  8. paulnjs commented on Oct 16, 2025

    @paulnjs
    Contributor

    Proposal

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

    The removed expense reappears in the report.

    What is the root cause of that problem?

    "You cannot move an expense from a report that is already approved."

    This is the error comes from backend. The report is marked as approved after changing the approver while in the UI we still allow editing the report field since isReportOutstanding still returns true for this report.

    App/src/libs/ReportUtils.ts

    Lines 4497 to 4499 in e4aabe2

    if (!isReportOutstanding(moneyRequestReport, moneyRequestReport.policyID)) {
    return false;
    }

    function isReportOutstanding(

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

    We can follow the same check hasForwardedAction to check if the report is changed approver or take control and will return false here if it's true. We can follow this approach and improve hasChangeApproverOrTakeControlAction by checking the list sorted report actions in the PR.

    function hasChangeApproverOrTakeControlAction(reportID: string): boolean {
        const reportActions = getAllReportActions(reportID);
        return Object.values(reportActions).some((action) => action?.actionName === CONST.REPORT.ACTIONS.TYPE.REROUTE || action?.actionName === CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL);
    }
    
    function isReportOutstanding(
        iouReport: OnyxInputOrEntry<Report>,
        policyID: string | undefined,
        reportNameValuePairs: OnyxCollection<ReportNameValuePairs> = allReportNameValuePair,
        allowSubmitted = true,
    ): boolean {
        ...
        return (
            ...
            !hasForwardedAction(iouReport.reportID) &&
            !hasChangeApproverOrTakeControlAction(iouReport.reportID) &&
            !isArchivedReport(reportNameValuePair)
        );
    }
    

    App/src/libs/ReportUtils.ts

    Lines 10487 to 10510 in e4aabe2

    function isReportOutstanding(
    iouReport: OnyxInputOrEntry<Report>,
    policyID: string | undefined,
    reportNameValuePairs: OnyxCollection<ReportNameValuePairs> = allReportNameValuePair,
    allowSubmitted = true,
    ): boolean {
    if (!iouReport || isEmptyObject(iouReport)) {
    return false;
    }
    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)

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Add a new test case to isReportOutstanding function and verify that this function returns false if the report is changed approver

    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.

  9. FitseTLT commented on Oct 21, 2025

    @FitseTLT
    Contributor

    This needs to be checked from BE and determined whether it is a bug from BE or we should avoid the action from FE.

    Currently the BE ChangeTransactionsReport is returning an error "You cannot move an expense from a report that is already approved." when removing an expense from a report while the report is still outstanding (not approved) but there is a new approver added on the report.

    🎀 👀 🎀 C+ reviewed

  10. melvin-bot commented on Oct 21, 2025

    @melvin-bot

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

  11. 20 remaining items

  12. m-natarajan commented on Dec 12, 2025

    @m-natarajan

    Reproduced, Windows 11 / Chrome, v9.2.75-9

    change.approver.mp4
  13. self-assigned this
    on Dec 18, 2025
  14. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 18, 2025
  15. melvin-bot commented on Dec 18, 2025

    @melvin-bot

    📣 @FitseTLT 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

    Offer link
    Upwork job

  16. s77rt commented on Dec 18, 2025

    @s77rt
    Member

    Going to check this one 👀

  17. s77rt commented on Dec 19, 2025

    @s77rt
    Member

    Update: Raised PR.

  18. s77rt commented on Dec 31, 2025

    @s77rt
    Member

    PR is deployed already. Can we get a retest on this

  19. jliexpensify commented on Dec 31, 2025

    @jliexpensify
    Contributor

    Requesting with QA

  20. m-natarajan commented on Dec 31, 2025

    @m-natarajan

    Not Reproducible in Windows 11 Chrome - v9.2.89-1

    bandicam.2025-12-31.08-43-50-859.mp4
  21. jliexpensify commented on Dec 31, 2025

    @jliexpensify
    Contributor

    Thanks everyone!

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.ExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions