-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat: Submit workspace creation + onboarding flow (Wave 2) #87283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abzokhattab
wants to merge
38
commits into
Expensify:main
Choose a base branch
from
abzokhattab:akhattab/87261-submit-workspace-onboarding
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
7a5368c
feat: Submit workspace creation + onboarding flow (Wave 2)
abzokhattab 0916a57
fix: load translations in WorkspaceOnboarding test
abzokhattab 5fcd638
test: add tests for Submit workspace onboarding flow
abzokhattab edfd362
chore: remove narration comment from CONST and trim hook JSDoc
abzokhattab fc5eb7c
test: improve coverage for Submit onboarding flow
abzokhattab 6aa9d5d
fix: use test user email in login list for validated private domain test
abzokhattab 98d9e67
Merge remote-tracking branch 'origin/main' into akhattab/87261-submit…
abzokhattab 96d920f
Merge remote-tracking branch 'origin/main' into akhattab/87261-submit…
abzokhattab 55728a8
fix: add SUBMIT to isPaidGroupPolicy and gate Purpose shortcut on isV…
abzokhattab 08e7035
fix: revert isPaidGroupPolicy to exclude Submit, add isSubmitPolicy/i…
abzokhattab 00e659c
fix: resolve onboarding loop for unvalidated private-domain EMPLOYER …
abzokhattab ad24a0c
fix: allow Submit workspace editors to access workspace feature pages
abzokhattab c0b38ab
fix: prettier formatting
abzokhattab fefc8ff
fixing prettier
abzokhattab 94aa343
fixing prettier
abzokhattab 81fbfa2
fix: resolve ESLint errors in CI
abzokhattab ef02c3f
fix: use canEditWorkspaceSettings in WorkspacePageWithSections fallba…
abzokhattab 791d430
Merge remote-tracking branch 'upstream/main' into akhattab/87261-subm…
abzokhattab 42984b7
Merge remote-tracking branch 'upstream/main' into akhattab/87261-subm…
abzokhattab 8d71e48
fix: show loading instead of not-found for joining workspaces, don't …
abzokhattab 762dcfc
test: add unit tests for useAutoCreateSubmitWorkspace hook
abzokhattab f8350d6
Merge remote-tracking branch 'upstream/main' into akhattab/87261-subm…
abzokhattab 9e50b03
Fix Submit workspace access gaps and onboarding NotFound flash
abzokhattab 5f1fd5b
Label Submit workspaces as "Submit" instead of "Free"
abzokhattab 5dc6eb6
Fix NotFound on approval workflow pages for Submit editors
abzokhattab 9106334
Merge remote-tracking branch 'upstream/main' into akhattab/87261-subm…
abzokhattab ca6b673
Prevent Submit editors from escalating members to admin
abzokhattab 608edba
Move Plan Type / Submit label hunks out of #87261 to #87263
abzokhattab 1884f9f
fix(test): disable no-restricted-syntax for navigateAfterOnboarding spy
abzokhattab 98d2824
Let Submit editors land on the upgrade page instead of NotFound
abzokhattab 12be0d7
Merge remote-tracking branch 'upstream/main' into akhattab/87261-subm…
abzokhattab 20adf33
Fix typecheck: use generateDefaultWorkspaceName after upstream rename
abzokhattab f42dbe7
Merge remote-tracking branch 'origin/main' into akhattab/87261-submit…
abzokhattab ac58c24
Merge remote-tracking branch 'upstream/main' into akhattab/87261-subm…
abzokhattab 42ee71e
Route Submit-beta onboarding joins through the Submit flow
abzokhattab 1efec60
Hide Reports sidebar entry on Submit workspaces
abzokhattab 9abb34c
Stamp Submit optimistic defaults when joining a workspace
abzokhattab 5aaf16e
Fix CI: spellcheck + joinAccessiblePolicy test expected args
abzokhattab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import {hasSeenTourSelector} from '@selectors/Onboarding'; | ||
|
abzokhattab marked this conversation as resolved.
|
||
| import {useCallback, useMemo} from 'react'; | ||
| import type {OnyxCollection} from 'react-native-onyx'; | ||
| import {navigateToSubmitWorkspaceAfterOnboardingWithMicrotaskQueue} from '@libs/navigateAfterOnboarding'; | ||
| import {createDisplayName} from '@libs/PersonalDetailsUtils'; | ||
| import {canEditWorkspaceSettings, isGroupPolicy} from '@libs/PolicyUtils'; | ||
| import {createWorkspace, generateDefaultWorkspaceName, generatePolicyID} from '@userActions/Policy/Policy'; | ||
| import {completeOnboarding} from '@userActions/Report'; | ||
| import {setOnboardingAdminsChatReportID, setOnboardingPolicyID} from '@userActions/Welcome'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import {lastWorkspaceNumberSelector} from '@src/selectors/Policy'; | ||
| import type {Policy} from '@src/types/onyx'; | ||
| import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; | ||
| import useHasActiveAdminPolicies from './useHasActiveAdminPolicies'; | ||
| import useLocalize from './useLocalize'; | ||
| import useOnboardingMessages from './useOnboardingMessages'; | ||
| import useOnyx from './useOnyx'; | ||
| import usePreferredPolicy from './usePreferredPolicy'; | ||
|
|
||
| /** | ||
| * Hook that provides a function to auto-create a Submit workspace for EMPLOYER | ||
| * users during onboarding and complete the onboarding flow. | ||
| * | ||
| * Shared by BaseOnboardingPersonalDetails, BaseOnboardingPurpose, and BaseOnboardingWorkspaces. | ||
| */ | ||
| function useAutoCreateSubmitWorkspace() { | ||
| const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID); | ||
| const [onboardingAdminsChatReportID] = useOnyx(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID); | ||
| const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); | ||
| const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector}); | ||
| const [betas] = useOnyx(ONYXKEYS.BETAS); | ||
| const [session] = useOnyx(ONYXKEYS.SESSION); | ||
| const groupPolicySelector = useMemo( | ||
| () => (policies: OnyxCollection<Policy>) => Object.values(policies ?? {}).some((policy) => isGroupPolicy(policy) && canEditWorkspaceSettings(policy)), | ||
| [], | ||
| ); | ||
| const lastWorkspaceNumberWithEmailSelector = useCallback( | ||
| (policies: OnyxCollection<Policy>) => { | ||
| return lastWorkspaceNumberSelector(policies, session?.email ?? ''); | ||
| }, | ||
| [session?.email], | ||
| ); | ||
| const [hasEditableGroupPolicy] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: groupPolicySelector}); | ||
| const [lastWorkspaceNumber] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: lastWorkspaceNumberWithEmailSelector}); | ||
| const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); | ||
| const currentUserPersonalDetails = useCurrentUserPersonalDetails(); | ||
| const {translate, formatPhoneNumber} = useLocalize(); | ||
| const {isRestrictedPolicyCreation} = usePreferredPolicy(); | ||
| const hasActiveAdminPolicies = useHasActiveAdminPolicies(); | ||
| const {onboardingMessages} = useOnboardingMessages(); | ||
|
|
||
| const autoCreateSubmitWorkspace = useCallback( | ||
| (firstName: string, lastName: string) => { | ||
| const shouldCreateWorkspace = !isRestrictedPolicyCreation && !onboardingPolicyID && !hasEditableGroupPolicy; | ||
| const displayName = createDisplayName(session?.email ?? '', {firstName, lastName}, formatPhoneNumber); | ||
|
|
||
| const {adminsChatReportID: newAdminsChatReportID, policyID: newPolicyID} = shouldCreateWorkspace | ||
| ? createWorkspace({ | ||
| policyOwnerEmail: undefined, | ||
| makeMeAdmin: true, | ||
| policyName: generateDefaultWorkspaceName(session?.email ?? '', lastWorkspaceNumber, translate, displayName), | ||
| policyID: generatePolicyID(), | ||
| engagementChoice: CONST.ONBOARDING_CHOICES.EMPLOYER, | ||
| currency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD, | ||
| file: undefined, | ||
| shouldAddOnboardingTasks: false, | ||
| introSelected, | ||
| activePolicyID, | ||
| currentUserAccountIDParam: session?.accountID ?? CONST.DEFAULT_NUMBER_ID, | ||
| currentUserEmailParam: session?.email ?? '', | ||
| shouldAddGuideWelcomeMessage: false, | ||
| type: CONST.POLICY.TYPE.SUBMIT, | ||
| betas, | ||
| isSelfTourViewed, | ||
| hasActiveAdminPolicies, | ||
| }) | ||
| : {adminsChatReportID: onboardingAdminsChatReportID, policyID: onboardingPolicyID}; | ||
|
|
||
| completeOnboarding({ | ||
| engagementChoice: CONST.ONBOARDING_CHOICES.EMPLOYER, | ||
| onboardingMessage: onboardingMessages[CONST.ONBOARDING_CHOICES.EMPLOYER], | ||
| firstName, | ||
| lastName, | ||
| adminsChatReportID: newAdminsChatReportID, | ||
| onboardingPolicyID: newPolicyID, | ||
| introSelected, | ||
| isSelfTourViewed, | ||
| betas, | ||
| }); | ||
|
|
||
| setOnboardingAdminsChatReportID(); | ||
| setOnboardingPolicyID(); | ||
|
|
||
| navigateToSubmitWorkspaceAfterOnboardingWithMicrotaskQueue(newPolicyID); | ||
| }, | ||
| [ | ||
| session?.email, | ||
| session?.accountID, | ||
| lastWorkspaceNumber, | ||
| translate, | ||
| formatPhoneNumber, | ||
| isRestrictedPolicyCreation, | ||
| onboardingPolicyID, | ||
| hasEditableGroupPolicy, | ||
| onboardingAdminsChatReportID, | ||
| currentUserPersonalDetails.localCurrencyCode, | ||
| introSelected, | ||
| activePolicyID, | ||
| isSelfTourViewed, | ||
| onboardingMessages, | ||
| betas, | ||
| hasActiveAdminPolicies, | ||
| ], | ||
| ); | ||
|
|
||
| return autoCreateSubmitWorkspace; | ||
| } | ||
|
|
||
| export default useAutoCreateSubmitWorkspace; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.