You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-05-28] [$250] [Exploratory] Report - Error appear after member change a submitted report to own Workspace #88530
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
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
User submits an expense in Workspace B → report enters PROCESSING status
isChangeWorkspaceAction() checks canEditReportPolicy(report, workspaceBPolicy) → returns true because isSubmitter && isAwaitingFirstLevelApproval(report) is true
User selects Workspace A → selectPolicy falls through to changeReportPolicy() (since user IS a member of target workspace)
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:
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.
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.
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
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):
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?
File:src/libs/ReportUtils.ts Function:canEditReportPolicy Description: Remove the submitter condition from the isSubmitted branch. Change:
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)
@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]
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
[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.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
MelvinBot commentedon May 13, 2026
Proposal
What is the root cause of that problem?
The client allows "Change Workspace" on a submitted expense report but the backend rejects the
ChangeReportPolicyAPI call, causing an optimistic rollback and the generic error message.The visibility gate
canEditReportPolicypermits the submitter to change workspace on a submitted (processing) expense report whenisAwaitingFirstLevelApprovalis true. The workspace selection page then callschangeReportPolicy, which sendsWRITE_COMMANDS.CHANGE_REPORT_POLICYto the backend with no client-side submitted-state validation. The backend rejects the request, triggering the failure data which surfacescommon.genericErrorMessage("Oops... something went wrong").Data flow
PROCESSINGstatusisChangeWorkspaceAction()checkscanEditReportPolicy(report, workspaceBPolicy)→ returnstruebecauseisSubmitter && isAwaitingFirstLevelApproval(report)istrueisWorkspaceEligibleForReportChangehas no submitted-state guard → Workspace A appears in the listselectPolicyfalls through tochangeReportPolicy()(since user IS a member of target workspace)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
ChangeReportPolicycommand in this scenario.Once the backend rejection reason is confirmed, the fix is one of:
If the backend intentionally blocks this — tighten the client-side gate so the option doesn't appear. The simplest approach: in
canEditReportPolicyatReportUtils.ts:4773-4774, remove theisSubmitter && isAwaitingFirstLevelApproval(report)branch for submitted expense reports, so onlyisManager || isAdmincan change workspace on a submitted report.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
changeReportPolicyitself (inReport/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 thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.melvin-bot commentedon May 13, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @cretadn22 (
External)melvin-bot commentedon May 13, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022054386273863604683
[-][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[/+]aswin-s commentedon May 13, 2026
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
canEditReportPolicyinsrc/libs/ReportUtils.tsincorrectly 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
For expense reports in the
isSubmittedstate, the function returnstruewhenisSubmitter && isAwaitingFirstLevelApproval(report)is true — granting the submitter a workspace-change option the backend will always reject. For expense reports in theisOpenstate, the guard correctly allowsisSubmitter || 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; onlyisManager || isAdminshould be permitted there.The only branch that requires a change is the
isSubmittedpath within theisExpenseTypeblock. TheisOpenbranch and the fallbackreturn isManager || isAdminat the end are intentional and correct — theisOpenbranch must remain unchanged because submitters legitimately can change workspace on open (unsubmitted) reports.canEditReportPolicyis consumed by all change-workspace entry points, most directly atReportChangeWorkspacePage.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
reporttyped asOnyxEntry<Report>, which isReport | null | undefined. All helper calls inside (isProcessingReport,isAwaitingFirstLevelApproval,isExpenseReport, etc.) already acceptOnyxEntry<Report>and handle nullish values internally, so no additional null guards are needed at thecanEditReportPolicylevel — existing callers and helpers already cover that boundary.What changes do you think we should make in order to solve the problem?
src/libs/ReportUtils.tsFunction:
canEditReportPolicyDescription: Remove the submitter condition from the
isSubmittedbranch. Change:to:
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. TheisOpenbranch (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 ofcanEditReportPolicy. No new null-safety logic is needed because the function already operates onOnyxEntry<Report>and all downstream helpers handle nullish inputs.What alternative solutions did you explore? (Optional)
N/A
18 remaining items
melvin-bot commentedon May 21, 2026
@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]
cretadn22 commentedon May 24, 2026
BugZero Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: Fix change workspace condition #62062 (comment)
Link to the comment on the Issue: [$250] [Due for payment 2025-06-02] Align
Change workspacecondition with what we have in OldDot #62337 (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:
[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/642752
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-709d-a615-a5c6-92cbc26ff2d4melvin-bot commentedon May 27, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon May 28, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon May 29, 2026
Payment Summary
Contributor+: @cretadn22 due $250 via NewDot
^ Test case created. Thx
JmillsExpensify commentedon Jun 1, 2026
$250 approved for @cretadn22