diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index bd66c2fae452..3869fd793ae5 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -791,7 +791,7 @@ function getOptions( (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) ) { // Generates an optimistic account ID for new users not yet saved in Onyx - const optimisticAccountID = UserUtils.generateAccountID(); + const optimisticAccountID = UserUtils.generateAccountID(searchValue); const personalDetailsExtended = { ...personalDetails, [optimisticAccountID]: { diff --git a/src/libs/PersonalDetailsUtils.js b/src/libs/PersonalDetailsUtils.js index 26c0a67aae48..f76b985c5feb 100644 --- a/src/libs/PersonalDetailsUtils.js +++ b/src/libs/PersonalDetailsUtils.js @@ -61,7 +61,7 @@ function getAccountIDsByLogins(logins) { const currentDetail = _.find(personalDetails, (detail) => detail.login === login); if (!currentDetail) { // generate an account ID because in this case the detail is probably new, so we don't have a real accountID yet - foundAccountIDs.push(UserUtils.generateAccountID()); + foundAccountIDs.push(UserUtils.generateAccountID(login)); } else { foundAccountIDs.push(Number(currentDetail.accountID)); } diff --git a/src/libs/UserUtils.js b/src/libs/UserUtils.js index 4202856c3e75..dffb5580f0d3 100644 --- a/src/libs/UserUtils.js +++ b/src/libs/UserUtils.js @@ -207,13 +207,12 @@ function getSmallSizeAvatar(avatarURL, accountID) { } /** - * Generate a random accountID. - * Uses the same approach of 'generateReportID'. - * + * Generate a random accountID base on searchValue. + * @param {String} searchValue * @returns {Number} */ -function generateAccountID() { - return Math.floor(Math.random() * 2 ** 21) * 2 ** 32 + Math.floor(Math.random() * 2 ** 32); +function generateAccountID(searchValue) { + return hashText(searchValue, 2 ** 32); } export { diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index bc1d4d6c3536..3b57ac6a2fae 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -496,7 +496,7 @@ function setAssigneeValue(assignee, assigneeAccountID, shareDestination, isCurre // Generate optimistic accountID if this is a brand new user account that hasn't been created yet if (!newAssigneeAccountID) { - newAssigneeAccountID = UserUtils.generateAccountID(); + newAssigneeAccountID = UserUtils.generateAccountID(assignee); } if (!isCurrentUser) { let newChat = {};