Skip to content

[Due for payment 2026-05-28] [$250] [Exploratory] Report - Error appear after member change a submitted report to own Workspace #88530

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: v9.3.61-2
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-21267/folder/13176670/41237098/1359026503
Email or phone of affected tester (no customers): leungbratt6+2204@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 10/Chrome
App Component: Chat Report View

Action Performed:

Precondition: User is an owner of Workspace A and is a member of Workspace B

  1. Navigate to the Workspace B chat
  2. Create a manual expense and submit it
  3. Click on the More button -> Change Workspace -> Select the own Workspace A

Expected Result:

Change Workspace should dismiss after user submit the report

Actual Result:

Error appears after selecting Change Workspace: "Oops... something went wrong and your request could not be completed. Please try again later."

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Video.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022054386273863604683
  • Upwork Job ID: 2054386273863604683
  • Last Price Increase: 2026-05-13
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    Bug
    and removed on May 13, 2026
  2. MelvinBot commented on May 13, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The client allows "Change Workspace" on a submitted expense report but the backend rejects the ChangeReportPolicy API call, causing an optimistic rollback and the generic error message.

    The visibility gate canEditReportPolicy permits the submitter to change workspace on a submitted (processing) expense report when isAwaitingFirstLevelApproval is true. The workspace selection page then calls changeReportPolicy, which sends WRITE_COMMANDS.CHANGE_REPORT_POLICY to the backend with no client-side submitted-state validation. The backend rejects the request, triggering the failure data which surfaces common.genericErrorMessage ("Oops... something went wrong").

    Data flow
    1. User submits an expense in Workspace B → report enters PROCESSING status
    2. isChangeWorkspaceAction() checks canEditReportPolicy(report, workspaceBPolicy) → returns true because isSubmitter && isAwaitingFirstLevelApproval(report) is true
    3. isWorkspaceEligibleForReportChange has no submitted-state guard → Workspace A appears in the list
    4. User selects Workspace A → selectPolicy falls through to changeReportPolicy() (since user IS a member of target workspace)
    5. Optimistic data is applied, API call fires → backend rejects → rollback + error

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

    This appears to be a backend/internal issue. A separate internal investigation is needed to determine why the backend rejects the ChangeReportPolicy command in this scenario.

    Once the backend rejection reason is confirmed, the fix is one of:

    1. If the backend intentionally blocks this — tighten the client-side gate so the option doesn't appear. The simplest approach: in canEditReportPolicy at ReportUtils.ts:4773-4774, remove the isSubmitter && isAwaitingFirstLevelApproval(report) branch for submitted expense reports, so only isManager || isAdmin can change workspace on a submitted report.

    2. If the backend should allow this — the backend needs to be updated, and the client code is already correct.

    What alternative solutions did you explore? (Optional)

    An alternative client-side approach would be to add validation in changeReportPolicy itself (in Report/index.ts) to check report status before making the API call and show a more descriptive error. However, preventing the option from appearing in the first place (option 1) is a better UX since users won't be offered an action that will fail.


    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.

  3. added
    External
    on May 13, 2026
  4. added
    Help Wanted
    on May 13, 2026
  5. melvin-bot commented on May 13, 2026

    @melvin-bot

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

  6. melvin-bot commented on May 13, 2026

    @melvin-bot
  7. changed the title [-][Exploratory] Report - Error appear after member change a submitted report to own Workspace[/-] [+][$250] [Exploratory] Report - Error appear after member change a submitted report to own Workspace[/+] on May 13, 2026
  8. aswin-s commented on May 13, 2026

    @aswin-s
    Contributor

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

    When a user who is an owner of their own Workspace A and a member of Workspace B submits an expense report in Workspace B, the report moves to processing state (awaiting first-level approval). If the user then selects More → Change Workspace → Workspace A, the option appears but attempting the action fails with "Oops... something went wrong and your request could not be completed. Please try again later." The backend correctly rejects this action because submitters should not be able to move already-submitted reports to different workspaces — only managers or admins should have this permission.

    What is the root cause of that problem?

    The visibility gate canEditReportPolicy in src/libs/ReportUtils.ts incorrectly permits submitters to change workspace on submitted (processing) expense reports. The function is structured as follows (lines 4748–4781):

    App/src/libs/ReportUtils.ts

    Lines 4768 to 4775 in d6a8779

    if (isExpenseType) {
    if (isOpen) {
    return isSubmitter || isAdmin;
    }
    if (isSubmitted) {
    return (isSubmitter && isAwaitingFirstLevelApproval(report)) || isManager || isAdmin;
    }

    For expense reports in the isSubmitted state, the function returns true when isSubmitter && isAwaitingFirstLevelApproval(report) is true — granting the submitter a workspace-change option the backend will always reject. For expense reports in the isOpen state, the guard correctly allows isSubmitter || isAdmin, because moving an unsubmitted draft to a different workspace is a legitimate submitter action. The submitted-report branch must not grant submitters this capability; only isManager || isAdmin should be permitted there.

    The only branch that requires a change is the isSubmitted path within the isExpenseType block. The isOpen branch and the fallback return isManager || isAdmin at the end are intentional and correct — the isOpen branch must remain unchanged because submitters legitimately can change workspace on open (unsubmitted) reports.

    canEditReportPolicy is consumed by all change-workspace entry points, most directly at ReportChangeWorkspacePage.tsx:152, which filters the eligible workspaces list shown to the user. Fixing the gate here fixes every surface that calls it.

    The function already receives report typed as OnyxEntry<Report>, which is Report | null | undefined. All helper calls inside (isProcessingReport, isAwaitingFirstLevelApproval, isExpenseReport, etc.) already accept OnyxEntry<Report> and handle nullish values internally, so no additional null guards are needed at the canEditReportPolicy level — existing callers and helpers already cover that boundary.

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

    1. File: src/libs/ReportUtils.ts
      Function: canEditReportPolicy
      Description: Remove the submitter condition from the isSubmitted branch. Change:
    if (isSubmitted) {
        return (isSubmitter && isAwaitingFirstLevelApproval(report)) || isManager || isAdmin;
    }

    to:

    if (isSubmitted) {
        return isManager || isAdmin;
    }

    This makes the submitted-report branch consistent with the fallback (return isManager || isAdmin) that handles all other non-open, non-submitted expense report states, and removes the path that lets a submitter surface a UI option the backend will always deny. The isOpen branch (return isSubmitter || isAdmin) is intentionally preserved — submitters are allowed to move their own unsubmitted drafts.

    Blast radius: The fix is scoped to a single condition inside canEditReportPolicy. It only affects the workspace-change visibility for submitted expense reports. It has no impact on IOU reports, invoice reports, open expense reports, other report editing permissions, or any other callers of canEditReportPolicy. No new null-safety logic is needed because the function already operates on OnyxEntry<Report> and all downstream helpers handle nullish inputs.

    What alternative solutions did you explore? (Optional)

    N/A

  9. 18 remaining items

  10. melvin-bot commented on May 21, 2026

    @melvin-bot

    @cretadn22 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]

  11. cretadn22 commented on May 24, 2026

    @cretadn22
    Contributor

    BugZero Checklist:

    Regression Test Proposal

    Precondition:

    Test:

    1. Log in as a user who is a member of multiple workspaces
    2. Create and submit an expense report
    3. As the submitter, verify you cannot change the workspace on the submitted report
    4. As a manager/admin, verify you can change the workspace on the submitted report
    5. Verify that no errors appear in the JS console

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-709d-a615-a5c6-92cbc26ff2d4
  12. added
    Weekly
    Daily
    Awaiting Payment
    and removed
    Daily
    Weekly
    on May 24, 2026
  13. melvin-bot commented on May 27, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  14. melvin-bot commented on May 28, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2054386273863604683/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  15. mallenexpensify commented on May 29, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @cretadn22 due $250 via NewDot

    ^ Test case created. Thx

  16. JmillsExpensify commented on Jun 1, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @cretadn22

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