-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Use newGenerateDefaultWorkspaceName in useAutoCreateTrackWorkspace and createWorkspaceFromIOUPayment #87135
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
Use newGenerateDefaultWorkspaceName in useAutoCreateTrackWorkspace and createWorkspaceFromIOUPayment #87135
Changes from 5 commits
a331d18
00be906
3834476
175f207
1b45858
2208fbb
e97e494
69048c5
eee5d53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -252,7 +252,7 @@ | |
| }; | ||
|
|
||
| const deprecatedAllPolicies: OnyxCollection<Policy> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.POLICY, | ||
| callback: (val, key) => { | ||
| if (!key) { | ||
|
|
@@ -268,7 +268,7 @@ | |
| }); | ||
|
|
||
| let deprecatedAllReportActions: OnyxCollection<ReportActions>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, | ||
| waitForCollectionCallback: true, | ||
| callback: (actions) => { | ||
|
|
@@ -278,7 +278,7 @@ | |
|
|
||
| let deprecatedSessionEmail = ''; | ||
| let deprecatedSessionAccountID = 0; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.SESSION, | ||
| callback: (val) => { | ||
| deprecatedSessionEmail = val?.email ?? ''; | ||
|
|
@@ -287,7 +287,7 @@ | |
| }); | ||
|
|
||
| let deprecatedAllPersonalDetails: OnyxEntry<PersonalDetailsList>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| callback: (val) => (deprecatedAllPersonalDetails = val), | ||
| }); | ||
|
|
@@ -2155,7 +2155,7 @@ | |
| Onyx.set(ONYXKEYS.DUPLICATE_WORKSPACE, {}); | ||
| } | ||
|
|
||
| function getDisplayNameForWorkspace(email: string) { | ||
| function getDisplayNameForWorkspace(email: string, displayNameOverride?: string) { | ||
| const emailParts = email.split('@'); | ||
| const domain = emailParts.at(1) ?? ''; | ||
| const isSMSDomain = `@${domain}` === CONST.SMS.DOMAIN; | ||
|
|
@@ -2169,7 +2169,7 @@ | |
| } | ||
|
|
||
| const userDetails = PersonalDetailsUtils.getPersonalDetailByEmail(email); | ||
| const displayName = userDetails?.displayName?.trim(); | ||
| const displayName = displayNameOverride?.trim() ?? userDetails?.displayName?.trim(); | ||
| if (displayName) { | ||
| return Str.UCFirst(displayName); | ||
| } | ||
|
|
@@ -2183,8 +2183,8 @@ | |
| * @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: string, lastWorkspaceNumber: number | undefined, localeTranslate: LocalizedTranslate): string { | ||
| const emailParts = email ? email.split('@') : deprecatedSessionEmail.split('@'); | ||
| function newGenerateDefaultWorkspaceName(email: string, lastWorkspaceNumber: number | undefined, localeTranslate: LocalizedTranslate, displayNameOverride?: string): string { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. displayNameOverride is from |
||
| const emailParts = email.split('@'); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the |
||
| if (!emailParts || emailParts.length !== 2) { | ||
| return ''; | ||
| } | ||
|
|
@@ -2195,7 +2195,7 @@ | |
| return localeTranslate('workspace.new.myGroupWorkspace', {workspaceNumber: lastWorkspaceNumber !== undefined ? lastWorkspaceNumber + 1 : undefined}); | ||
| } | ||
|
|
||
| const displayNameForWorkspace = getDisplayNameForWorkspace(email || deprecatedSessionEmail); | ||
| const displayNameForWorkspace = getDisplayNameForWorkspace(email, displayNameOverride); | ||
|
|
||
| return localeTranslate('workspace.new.workspaceName', displayNameForWorkspace, lastWorkspaceNumber !== undefined ? lastWorkspaceNumber + 1 : undefined); | ||
| } | ||
|
|
@@ -3942,6 +3942,8 @@ | |
| currentUserEmail: string, | ||
| iouReportOwnerEmail: string, | ||
| conciergeReportID: string | undefined, | ||
| lastWorkspaceNumber: number | undefined, | ||
| localeTranslate: LocalizedTranslate, | ||
| ): WorkspaceFromIOUCreationData | undefined { | ||
| // This flow only works for IOU reports | ||
| if (!iouReport || !ReportUtils.isIOUReportUsingReport(iouReport)) { | ||
|
|
@@ -3950,7 +3952,7 @@ | |
|
|
||
| // Generate new variables for the policy | ||
| const policyID = generatePolicyID(); | ||
| const workspaceName = generateDefaultWorkspaceName(currentUserEmail); | ||
| const workspaceName = newGenerateDefaultWorkspaceName(currentUserEmail, lastWorkspaceNumber, localeTranslate); | ||
| const employeeAccountID = iouReport?.ownerAccountID; | ||
| const {customUnits, customUnitID, customUnitRateID} = buildOptimisticDistanceRateCustomUnits(iouReport?.currency); | ||
| const oldPersonalPolicyID = iouReport?.policyID; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.