Create a new generateDefaultWorkspaceName#85789
Create a new generateDefaultWorkspaceName#85789bernhardoj wants to merge 5 commits intoExpensify:mainfrom
Conversation
|
@parasharrajat 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f5ac7daf1
ℹ️ 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".
src/libs/actions/App.ts
Outdated
| type?: PolicyType; | ||
| // TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417) | ||
| betas?: OnyxEntry<OnyxTypes.Beta[]>; | ||
| lastWorkspaceNumber: number | undefined; |
There was a problem hiding this comment.
Pass
lastWorkspaceNumber to the name generator
This new parameter never gets consumed inside createWorkspaceWithPolicyDraftAndNavigateToIt(): the function still calls createDraftInitialWorkspace()/createWorkspace() without it, and those paths still fall back to generateDefaultWorkspaceName(). In the /transition?...exitTo=workspace/new flow this change is targeting, the new selector/hook becomes a no-op, so users who already have "… Workspace" workspaces still get another base name instead of the expected incremented suffix.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| App.setUpPoliciesAndNavigate(session, introSelected, activePolicyID, isSelfTourViewed); | ||
| App.setUpPoliciesAndNavigate(session, introSelected, activePolicyID, isSelfTourViewed, lastWorkspaceNumber); |
There was a problem hiding this comment.
Delay transition workspace creation until policies hydrate
lastWorkspaceNumber is read inside a mount-only effect, so setUpPoliciesAndNavigate() only ever sees the first render’s value. On fresh logins or cleared caches, useLastWorkspaceNumber() will still be undefined when this effect runs, and the workspace is auto-created before openApp()/reconnectApp() finish hydrating the policy collection. Because the effect never reruns when the selector updates, the duplicate-name case still reproduces in that environment.
Useful? React with 👍 / 👎.
| @@ -0,0 +1,15 @@ | |||
| import type {OnyxCollection} from 'react-native-onyx'; | |||
| import useOnyx from '@hooks/useOnyx'; | |||
src/libs/actions/Policy/Policy.ts
Outdated
| * @param [email] the email to base the workspace name on. If not passed, will use the logged-in user's email instead | ||
| * @param [lastWorkspaceNumber] the last workspace number | ||
| */ | ||
| function newGenerateDefaultWorkspaceName(email = '', lastWorkspaceNumber: number | undefined): string { |
|
Hmm, somehow some of my changes are not commited 🤦 |
Explanation of Change
Fixed Issues
$ #66574
PROPOSAL:
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mp4