-
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
Merged
cristipaval
merged 9 commits into
Expensify:main
from
bernhardoj:chore/66574-refactor-policy-to-use-useonyx-14
Apr 7, 2026
Merged
Use newGenerateDefaultWorkspaceName in useAutoCreateTrackWorkspace and createWorkspaceFromIOUPayment #87135
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a331d18
remove deprecatedSessionEmail usage
bernhardoj 00be906
add displayNameOverride
bernhardoj 3834476
use the new getDisplayNameForWorkspace
bernhardoj 175f207
add missing translate
bernhardoj 1b45858
lint
bernhardoj 2208fbb
update jsdoc
bernhardoj e97e494
fix test
bernhardoj 69048c5
fix test
bernhardoj eee5d53
prettier
bernhardoj 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
| 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); | ||
| } | ||
|
|
@@ -2179,12 +2179,10 @@ | |
| } | ||
|
|
||
| /** | ||
| * Generate a policy name based on an email and policy list. | ||
| * @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 | ||
| * Generate a policy name based on an email and 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 +2193,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 +3940,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 +3950,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; | ||
|
|
||
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.
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.