Skip to content

[CP Staging] Revert "Align workspace selector logic" - #102134

Merged
lakchote merged 3 commits into
mainfrom
revert-101430-fix/align-workspace-selector-logic
Sep 24, 2026
Merged

lakchote merged 3 commits into
mainfrom
revert-101430-fix/align-workspace-selector-logic

Conversation

@mountiny

Copy link
Copy Markdown
Contributor

Reverts #101430

Fixed issues

$ #102130

@mountiny mountiny self-assigned this Sep 24, 2026
@mountiny
mountiny requested review from a team as code owners September 24, 2026 08:15
@melvin-bot
melvin-bot Bot requested review from sobitneupane and trjExpensify and removed request for a team September 24, 2026 08:15
@melvin-bot

melvin-bot Bot commented Sep 24, 2026

Copy link
Copy Markdown

@sobitneupane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed the request for review from a team September 24, 2026 08:15
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8c069f3a3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

const lockedPreferredPolicy = isRestrictedToPreferredPolicy ? groupPoliciesWithChatEnabled.find((policy) => policy?.id === preferredPolicyID) : undefined;
const isLockedToPreferredPolicy = !!lockedPreferredPolicy;
const defaultChatEnabledPolicy = lockedPreferredPolicy ?? getDefaultChatEnabledPolicy(groupPoliciesWithChatEnabled as Array<OnyxEntry<OnyxTypes.Policy>>, activePolicy) ?? undefined;
const defaultChatEnabledPolicy = getDefaultChatEnabledPolicy(groupPoliciesWithChatEnabled as Array<OnyxEntry<OnyxTypes.Policy>>, activePolicy);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Honor the domain's restricted preferred workspace

When a member's security group enables a restrictedPrimaryPolicyID and that eligible workspace differs from the active one, this normal resolver selects the active workspace (or no default) instead. The Create flow can consequently create the report in the active workspace or present a selector containing all eligible workspaces, rather than using the configured restricted workspace; restore the preferred-policy override before resolving the default.

Useful? React with 👍 / 👎.

Comment on lines 35 to +36
const chatEnabledPaidGroupPoliciesSelector = (policies: OnyxCollection<OnyxTypes.Policy>, currentUserLogin: string | undefined) =>
getGroupPoliciesWhereReportCanBeCreated(policies, currentUserLogin);
getGroupPoliciesWhereReportCanBeCreated(policies, currentUserLogin).slice(0, 2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the active workspace before limiting candidates

When a user has three or more eligible workspaces and the active workspace is not among the first two collection values, this slice removes it before getDefaultChatEnabledPolicy runs. That resolver then has no default, so clicking Create opens the workspace selector instead of creating directly in the active workspace; retain the active workspace in the capped list (or avoid the cap).

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...rch/SearchRouter/useCreateNavigationSuggestions.ts 98.70% <100.00%> (+0.01%) ⬆️
src/hooks/useCreateReport.tsx 100.00% <100.00%> (ø)
src/pages/Search/EmptySearchView.tsx 74.82% <66.66%> (+0.17%) ⬆️
...BPopoverContent/menuItems/CreateReportMenuItem.tsx 87.50% <83.33%> (+1.29%) ⬆️
... and 7 files with indirect coverage changes

@github-actions

This comment has been minimized.

lakchote
lakchote previously approved these changes Sep 24, 2026

@lakchote lakchote left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

cristipaval
cristipaval previously approved these changes Sep 24, 2026
@jmusial

jmusial commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

@lakchote @cristipaval patch fixing lint errors below I have no permissions to push as it's main repo not swm fork

diff --git a/src/pages/Search/EmptySearchView.tsx b/src/pages/Search/EmptySearchView.tsx
--- a/src/pages/Search/EmptySearchView.tsx
+++ b/src/pages/Search/EmptySearchView.tsx
@@ -157,7 +157,7 @@ function EmptySearchViewContent({
     const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});
     const [rules] = useOnyx(ONYXKEYS.COLLECTION.RULE);
 
-    const defaultChatEnabledPolicy = getDefaultChatEnabledPolicy(groupPoliciesWithChatEnabled as Array<OnyxEntry<Policy>>, activePolicy);
+    const defaultChatEnabledPolicy = getDefaultChatEnabledPolicy(groupPoliciesWithChatEnabled, activePolicy);
 
     const filteredPolicyID = getFilterFromQuery(queryJSON, CONST.SEARCH.SYNTAX_FILTER_KEYS.POLICY_ID);
     let isFilteredWorkspaceAccessible = true;
diff --git a/src/pages/inbox/sidebar/FABPopoverContent/menuItems/CreateReportMenuItem.tsx b/src/pages/inbox/sidebar/FABPopoverContent/menuItems/CreateReportMenuItem.tsx
--- a/src/pages/inbox/sidebar/FABPopoverContent/menuItems/CreateReportMenuItem.tsx
+++ b/src/pages/inbox/sidebar/FABPopoverContent/menuItems/CreateReportMenuItem.tsx
@@ -24,7 +24,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
 import {sessionEmailAndAccountIDSelector} from '@src/selectors/Session';
 import type * as OnyxTypes from '@src/types/onyx';
 
-import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
+import type {OnyxCollection} from 'react-native-onyx';
 
 import {isTrackIntentUserSelector} from '@selectors/Onboarding';
 import React from 'react';
@@ -54,7 +54,7 @@ function CreateReportMenuItem() {
     const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});
     const [rules] = useOnyx(ONYXKEYS.COLLECTION.RULE);
 
-    const defaultChatEnabledPolicy = getDefaultChatEnabledPolicy(groupPoliciesWithChatEnabled as Array<OnyxEntry<OnyxTypes.Policy>>, activePolicy);
+    const defaultChatEnabledPolicy = getDefaultChatEnabledPolicy(groupPoliciesWithChatEnabled, activePolicy);
 
     const isReportInSearch = isOnSearchMoneyRequestReportPage();

@lakchote
lakchote dismissed stale reviews from cristipaval and themself via 82bd307 September 24, 2026 09:12
@lakchote

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

@lakchote lakchote left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lakchote
lakchote merged commit c30f0c3 into main Sep 24, 2026
44 of 47 checks passed
@lakchote
lakchote deleted the revert-101430-fix/align-workspace-selector-logic branch September 24, 2026 09:19
@github-actions

Copy link
Copy Markdown
Contributor

🚧 lakchote has triggered a test Expensify/App build. You can view the workflow run here.

OSBotify pushed a commit that referenced this pull request Sep 24, 2026
…kspace-selector-logic

[CP Staging] Revert "Align workspace selector logic"

(cherry picked from commit c30f0c3)

(cherry-picked to staging by lakchote)
@OSBotify OSBotify added the CP Staging marks PRs that have been CP'd to staging label Sep 24, 2026
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@os-botify

os-botify Bot commented Sep 24, 2026

Copy link
Copy Markdown

🔁 Filed a Staging retest request for deploy blockers #102130 after this PR was cherry-picked to staging.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/lakchote in version: 9.4.92-8 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

MelvinBot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

No help site changes are required

This PR is a pure revert of internal workspace-resolution logic. It restores the exact behavior the help site already describes, so no draft PR was created.

What this PR changes: it reverts Align workspace selector logic, which had (1) made Create report skip the workspace selector when a domain security group locks the user to a Preferred Workspace, and (2) kept the default workspace inside the FAB's two-workspace slice. Reverting puts both back to how they shipped before.

Why no docs change:

UI verification (web)

I confirmed the documented labels and flow against the live app rather than assuming:

Documented Live UI Result
+ Create entry point + icon button with a Create tooltip (FloatingActionButton.tsx:90) ✅ matches
Create report menu item Create report ✅ matches
Draft opens on the default workspace Opened directly on the default workspace, no selector ✅ matches
More > Change workspace Not shown on the test account ✅ expected — isChangeWorkspaceAction requires 2+ eligible workspaces, and the test account had one

FAB menu showing Create report Draft report created on the default workspace

One thing to watch

docs/articles/new-expensify/domains/Create-and-Manage-Domain-Groups.md:89 says a Preferred Workspace will "automatically route a group's expenses and reports to a specific workspace." After this revert, Create report does not honor the Preferred Workspace — that is the open bug in Creating new report via FAB automatically uses default WS, not the Preferred one. and Create report workspace selector ignores domain restrictions and misfires on the FAB.

I did not change that line, because documenting a bug that is actively being fixed would be wrong. It should stay accurate once the fix lands correctly. If you'd rather add a temporary caveat there, reply and I'll open the draft PR.


@mountiny — no help site PR was created, so there is nothing to mark Ready for review. Let me know if you disagree with the assessment above and I'll open one.


view run · view recording

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.92-8 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/lakchote in version: 9.4.93-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

Confirmed again: no help site changes are required

I re-ran this review after the revert deployed to production in 9.4.92-8. The conclusion is unchanged from my earlier comment on this PR, so I did not create a draft PR.

Why no docs change:

  • Align workspace selector logic — the PR being reverted — shipped zero docs/ files, so there is no help site copy to roll back.
  • This PR touches only src/ and tests/. No feature names, tab names, settings labels, or buttons changed.
  • The only article covering this flow, docs/articles/new-expensify/reports-and-expenses/Create-and-Submit-Reports.md:15-16, already says reports open on your default workspace — which is exactly the restored behavior.
  • I swept every new-expensify article for wording describing a workspace-selection step during report creation. Nothing documents the selector this PR affects, so there is no stale text to correct.

I verified the documented labels against the live UI last run at this same commit — + Create (a + icon with a Create tooltip, FloatingActionButton.tsx:90), the Create report menu item, and the draft opening directly on the default workspace all matched the article. No code changed since, so that verification still stands.

Still worth a decision from you

docs/articles/new-expensify/domains/Create-and-Manage-Domain-Groups.md:89 says a Preferred Workspace will "automatically route a group's expenses and reports to a specific workspace." With this revert now in production, Create report does not honor the Preferred Workspace — the open bug in Creating new report via FAB automatically uses default WS, not the Preferred one. and Create report workspace selector ignores domain restrictions and misfires on the FAB.

I left that line alone, because documenting a bug that is actively being fixed would make the article wrong again as soon as the fix lands. If you'd rather ship a temporary caveat there, reply and I'll open the draft PR.


@mountiny — there is no help site PR to review or mark Ready for review, because no changes are required. Tell me if you disagree with the assessment above and I'll open one.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.93-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@tgolen tgolen mentioned this pull request Sep 29, 2026
40 tasks done
@jmusial jmusial mentioned this pull request Oct 2, 2026
43 tasks done
roryabraham pushed a commit that referenced this pull request Oct 20, 2026
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/lakchote in version: 9.5.15-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update is needed. This PR reverts Align workspace selector logic, and that change's docs PR ([HOLD] Docs updates for E/A#101430 clarify which workspace new reports open on) was closed without merging. The articles still say what this revert restores: "Select Create report to open a draft report on your default workspace" (Create-and-Submit-Reports.md:15).


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.5.15-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

CP Staging marks PRs that have been CP'd to staging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants