Skip to content

[Due for payment 2025-06-02] [$250] Move expense - Expense can be moved to report of deleted workspace #62552

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.1.49-4
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): dhsishdsiushbishd@gmail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.4 / Chrome
App Component: Money Requests

Action Performed:

  1. Go to staging.new.expensify.com
  2. Create a workspace.
  3. Go to workspace chat.
  4. Submit an expense to the workspace chat.
  5. Delete the workspace.
  6. Create another workspace.
  7. Go to workspace chat.
  8. Submit an expense to the workspace chat.
  9. Click on the expense preview.
  10. Click More > Move expense.
  11. Select the expense report of the deleted workspace.

Expected Result:

Expense report from the deleted workspace should not appear in the Report list when moving expense.
Reports from other workspaces should not appear in the Report list (production behavior).

Actual Result:

Expense report from the deleted workspace appears in the Report list when moving expense.

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

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021925500566534762869
  • Upwork Job ID: 1925500566534762869
  • Last Price Increase: 2025-05-22
  • Automatic offers:
    • nkdengineer | Contributor | 107407062
Issue OwnerCurrent Issue Owner: @bfitzexpensify

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 22, 2025
  2. melvin-bot commented on May 22, 2025

    @melvin-bot

    Triggered auto assignment to @bfitzexpensify (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 May 22, 2025

    @melvin-bot

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

  4. melvin-bot commented on May 22, 2025

    @melvin-bot

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

  5. github-actions commented on May 22, 2025

    @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. nkdengineer commented on May 22, 2025

    @nkdengineer
    Contributor

    Proposal

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

    Expense report from the deleted workspace appears in the Report list when moving expense.

    What is the root cause of that problem?

    It comes from #62270. But the current problem is isReportOutstanding function doesn't return false for archived reports.

    const expenseReports = useMemo(
    () =>
    Object.values(allPoliciesID ?? {}).flatMap((policyID) => {
    if (!policyID) {
    return [];
    }
    const reports = getOutstandingReportsForUser(policyID, currentUserPersonalDetails.accountID, allReports ?? {});
    return reports;
    }),
    [allPoliciesID, allReports, currentUserPersonalDetails.accountID],
    );
    const reportOptions: ReportListItem[] = useMemo(() => {
    if (!allReports) {
    return [];

    App/src/libs/ReportUtils.ts

    Lines 9640 to 9647 in 6871ba9

    function getOutstandingReportsForUser(policyID: string | undefined, reportOwnerAccountID: number | undefined, reports: OnyxCollection<Report> = allReports): Array<OnyxEntry<Report>> {
    if (!reports) {
    return [];
    }
    return Object.values(reports)
    .filter((report) => isReportOutstanding(report, policyID) && report?.ownerAccountID === reportOwnerAccountID)
    .sort((a, b) => a?.reportName?.localeCompare(b?.reportName?.toLowerCase() ?? '') ?? 0);
    }

    App/src/libs/ReportUtils.ts

    Lines 9618 to 9630 in 6871ba9

    function isReportOutstanding(iouReport: OnyxInputOrEntry<Report>, policyID: string | undefined): boolean {
    if (!iouReport || isEmptyObject(iouReport)) {
    return false;
    }
    return (
    isExpenseReport(iouReport) &&
    iouReport?.stateNum !== undefined &&
    iouReport?.statusNum !== undefined &&
    iouReport?.policyID === policyID &&
    iouReport?.stateNum <= CONST.REPORT.STATE_NUM.SUBMITTED &&
    iouReport?.statusNum <= CONST.REPORT.STATUS_NUM.SUBMITTED &&
    !hasForwardedAction(iouReport.reportID)
    );

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

    We should return false for archived report here

    const reportNameValuePair = allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReport.reportID}`] ?? {};
    
    return (
        isExpenseReport(iouReport) &&
        iouReport?.stateNum !== undefined &&
        iouReport?.statusNum !== undefined &&
        iouReport?.policyID === policyID &&
        iouReport?.stateNum <= CONST.REPORT.STATE_NUM.SUBMITTED &&
        iouReport?.statusNum <= CONST.REPORT.STATUS_NUM.SUBMITTED &&
        !hasForwardedAction(iouReport.reportID) && 
        !isArchivedReport(reportNameValuePair)
    );
    

    App/src/libs/ReportUtils.ts

    Lines 9618 to 9630 in 6871ba9

    function isReportOutstanding(iouReport: OnyxInputOrEntry<Report>, policyID: string | undefined): boolean {
    if (!iouReport || isEmptyObject(iouReport)) {
    return false;
    }
    return (
    isExpenseReport(iouReport) &&
    iouReport?.stateNum !== undefined &&
    iouReport?.statusNum !== undefined &&
    iouReport?.policyID === policyID &&
    iouReport?.stateNum <= CONST.REPORT.STATE_NUM.SUBMITTED &&
    iouReport?.statusNum <= CONST.REPORT.STATUS_NUM.SUBMITTED &&
    !hasForwardedAction(iouReport.reportID)
    );

    Or we can filter out it here

    App/src/libs/ReportUtils.ts

    Lines 9640 to 9647 in 6871ba9

    function getOutstandingReportsForUser(policyID: string | undefined, reportOwnerAccountID: number | undefined, reports: OnyxCollection<Report> = allReports): Array<OnyxEntry<Report>> {
    if (!reports) {
    return [];
    }
    return Object.values(reports)
    .filter((report) => isReportOutstanding(report, policyID) && report?.ownerAccountID === reportOwnerAccountID)
    .sort((a, b) => a?.reportName?.localeCompare(b?.reportName?.toLowerCase() ?? '') ?? 0);
    }

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

    Update getOutstandingReportsForUser test and verify the result doesn't include the archived report.

    What alternative solutions did you explore? (Optional)

    NA

    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.

  7. lakchote commented on May 22, 2025

    @lakchote
    Contributor
  8. 33 remaining items

  9. melvin-bot commented on May 26, 2025

    @melvin-bot

    @rojiphil @bfitzexpensify @rojiphil 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]

  10. bfitzexpensify commented on Jun 2, 2025

    @bfitzexpensify
    Contributor

    Payment complete to @nkdengineer

    @rojiphil, please complete the BZ checklist

  11. melvin-bot commented on Jun 6, 2025

    @melvin-bot

    @bfitzexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  12. rojiphil commented on Jun 6, 2025

    @rojiphil
    Contributor

    BZ Checklist is pending from my end. Will do it today.

  13. rojiphil commented on Jun 7, 2025

    @rojiphil
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production
    • 2b. Reported on staging (deploy blocker)
    • 2c. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [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:

    • [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: Not Required. The existing checklist is good enough to capture such issues.

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

    Precondition:

    Test:

    1. Create a new workspace
    2. Go to WS chat and create a new expense
    3. Open expense report in the step 2
    4. Select any expense > Move expense
    5. Verify that the archived report doesn't appear in the list

    Do we agree 👍 or 👎

  14. rojiphil commented on Jun 7, 2025

    @rojiphil
    Contributor

    @bfitzexpensify BZ Checklist Done. Thanks.

  15. melvin-bot commented on Jun 9, 2025

    @melvin-bot

    @bfitzexpensify 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  16. luacmartins commented on Jun 9, 2025

    @luacmartins
    Contributor

    What's left here before we can close this issue?

  17. bfitzexpensify commented on Jun 10, 2025

    @bfitzexpensify
    Contributor

    Payment summary:

    @rojiphil due $250 payment through NewDot Manual Requests

  18. garrettmknight commented on Jun 19, 2025

    @garrettmknight
    Contributor

    $250 approved for @rojiphil

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions