Skip to content

Spend - Actual workspace is not checked during "Change Workspace" process. #106600

Open

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.36-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #104295
Email or phone of affected tester (no customers): ibellicotest+3215@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome
App Component: Search

Action Performed:

Prerequisite: Account has at least two workspaces.
Prerequisite 2: At least one report created in one workspace chat.

  1. Open the staging.new.expensify.com website.
  2. Navigate to "Spend" > "Reports"
  3. Select a report > "Change Workspace"
  4. When RHP with workspaces list opens, note that actual workspace is not checked.

Expected Result:

The actual workspace where report was created, should be displayed checked during the "Change Workspace" process.

Actual Result:

The actual workspace where report was created, is not displayed checked during the "Change Workspace" process.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7310751_1794367092016.Changed_1.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7310751

Issue OwnerCurrent Issue Owner: @allgandalf

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 11, 2026
  2. applause-bot commented on Nov 11, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/f54e1581bbc874762d20cefe72915fc9db1dc4b801dded51170565e13eef76e8

  3. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #104295

  4. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    @JS00001 @mollfpr @Eskalifer1 you have been assigned to this deploy blocker because you reviewed the offending PR: #104295

  5. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    @allgandalf you have been assigned to this deploy blocker because you authored the offending PR: #104295

  6. melvin-bot commented on Nov 11, 2026

    @melvin-bot

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

  7. github-actions commented on Nov 11, 2026

    @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.
  8. MelvinBot commented on Nov 11, 2026

    @MelvinBot
    Contributor

    Proposal

    Recommendation: roll forward with a focused fix. Keep the deploy blocker until verification passes.

    What is the root cause of that problem?

    Add Change workspace to Search bulk actions introduced a workspace picker that starts without a selected workspace instead of using the report’s current workspace.

    Code evidence and attribution

    The PR introduces this page and its faulty initialization; attribution is supported by its diff, not just the automated assignments.

    Scope caveat: This explains the Search selected-report action. The existing report-detail picker already falls back to the report’s current workspace. If the recording shows that separate route, further investigation is needed.

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

    Initialize the checked workspace from the explicitly selected report’s current workspace, while allowing a newly chosen destination to override it.

    • Keep Save disabled until the destination actually changes.
    • Do not preselect an arbitrary workspace for mixed-workspace selections.
    • Do not infer the workspace of all matching reports from only loaded results.
    • Fix the Search page, not the shared workspace-list hook.

    Verify that opening the picker checks the current workspace, choosing another workspace updates the check and enables Save, and reopening after saving checks the new workspace. Cover mixed-workspace and unloaded “Select all” cases.

    What alternative solutions did you explore?

    Reverting the feature would remove the affected flow, but a focused fix is more proportionate for this defect alone.

    Verification limitation: Code investigation completed; browser reproduction and fix verification were not performed. No code changes were made.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/106600) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  9. mollfpr commented on Nov 11, 2026

    @mollfpr
    Contributor

    This is minor, so I'm removing the blocker label. We can fix it separately.

  10. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Nov 11, 2026
  11. Eskalifer1 commented on Nov 11, 2026

    @Eskalifer1
    Contributor

    This is the only blocker so far that directly relates to the PR and wasn't discussed during the PR review.

    That said, I wouldn't even call it a bug or a regression:

    • It was never discussed, and it was implemented this way from the very beginning: there is no single selected item, since the selected reports can be from different workspaces.
    • If all the reports are from the same workspace, the Save button is disabled when that workspace is selected.

    I think this is a issue for a follow-up.

    cc: @mollfpr @allgandalf

  12. cocvn157 commented on Nov 15, 2026

    @cocvn157

    Proposal

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

    When a user selects a report (or multiple reports belonging to the same workspace) on Spend > Reports and opens Change Workspace (SearchChangeWorkspacePage), the workspace list RHP opens with no workspace checked, whereas opening Change Workspace from a report (DynamicReportChangeWorkspacePage) checks and pins the report's current workspace while keeping Save disabled until a different workspace is chosen.

    What is the root cause of that problem?

    1. In src/pages/Search/SearchChangeWorkspacePage.tsx:
      const [policyID, setPolicyID] = useState<string>();
      ...
      const {data, shouldShowNoResultsFoundMessage, shouldShowSearchInput} = useWorkspaceList({
          policies,
          currentUserLogin: session?.email,
          shouldShowPendingDeletePolicy: false,
          selectedPolicyIDs: policyID ? [policyID] : undefined,
          // An empty list keeps the picked workspace where it is instead of moving it to the top.
          policyIDsToSortToTop: [],
          searchTerm: debouncedSearchTerm,
          localeCompare,
          additionalFilter: canMoveAReportTo,
      });
      • policyID starts as undefined with no fallback to the current workspace of the selected report(s), so selectedPolicyIDs is undefined on initial render and useWorkspaceList marks every row isSelected: false.
      • Interestingly, the Save button's isDisabled check at line 180 already accounts for the case where all selected reports share a single policyID:
        isDisabled: !policyID || (!areAllMatchingItemsSelected && selectedReports.every((report) => report.policyID === policyID)),
      • However, notice also that selectedReports[i].policyID comes from the Search selection state, while if a report was already moved once in the same session, the live Onyx report (selectedOnyxReports['report_' + reportID].policyID) via movableReports (lines 67–82) holds the up-to-date policyID!

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

    Align SearchChangeWorkspacePage.tsx with DynamicReportChangeWorkspacePage.tsx (src/pages/DynamicReportChangeWorkspacePage.tsx, lines 132–135 & 246–250) when all explicitly selected movable reports share a single current workspace (!areAllMatchingItemsSelected):

    1. Derive commonCurrentPolicyID from the selected reports (preferring live Onyx report policyID via movableReports):
      • In src/pages/Search/SearchChangeWorkspacePage.tsx:
        const [draftPolicyID, setDraftPolicyID] = useState<string>();
        const uniqueCurrentPolicyIDs = !areAllMatchingItemsSelected
            ? [...new Set(movableReports.map((report) => report.policyID).filter((id): id is string => !!id))]
            : [];
        const commonCurrentPolicyID = uniqueCurrentPolicyIDs.length === 1 ? uniqueCurrentPolicyIDs.at(0) : undefined;
        const currentSelection = draftPolicyID ?? commonCurrentPolicyID;
        const initialSelection = useInitialSelection(currentSelection, {resetOnFocus: true});
    2. Pass currentSelection and initialSelection to useWorkspaceList and SelectionList:
      • Pass selectedPolicyIDs: currentSelection ? [currentSelection] : undefined and policyIDsToSortToTop: initialSelection ? [initialSelection] : [] to useWorkspaceList.
      • Pass initiallyFocusedItemKey={initialSelection} and onSelectRow={(option) => setDraftPolicyID(option.policyID)} to SelectionList.
      • Update confirmButtonOptions.isDisabled and changeWorkspace to use currentSelection:
        isDisabled: !currentSelection || (!!commonCurrentPolicyID && currentSelection === commonCurrentPolicyID),
      • This ensures that:
        • When a single report (or multiple reports from the same workspace) is selected, its current workspace is checked and pinned to the top on open, with Save disabled until a different workspace is selected.
        • If a report is moved to Workspace B and Change Workspace is opened again, movableReports reads the live selectedOnyxReports policyID, so Workspace B is checked immediately.
        • When reports from multiple different workspaces are selected (uniqueCurrentPolicyIDs.length > 1) or "Select all" across pages (areAllMatchingItemsSelected) is active, commonCurrentPolicyID is undefined, so no workspace is pre-checked.

    What alternative approaches did you explore? (Optional)

    Checking selectedReports.every((report) => report.policyID === ...) directly on selectedReports was considered, but reading report.policyID from movableReports (which merges selectedOnyxReports via getReportFromSearchSnapshot) is strictly better because selectedReports in SearchSelectionContext is seeded from the Search snapshot, whereas selectedOnyxReports reflects live workspace moves immediately.

  13. JS00001 commented on Nov 16, 2026

    @JS00001
    Contributor

    @allgandalf lets follow up on this please

  14. Eskalifer1 commented on Nov 16, 2026

    @Eskalifer1
    Contributor

    Left comment here: #106601 (comment)

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.DailyKSv2EngineeringOverdue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions