Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
if (!isEmpty(htmlAttribAccountID) && personalDetails?.[htmlAttribAccountID]) {
const user = personalDetails[htmlAttribAccountID];
accountID = parseInt(htmlAttribAccountID, 10);
mentionDisplayText = formatPhoneNumber(user?.login ?? '') || getDisplayNameOrDefault(user);
mentionDisplayText = getDisplayNameOrDefault(user) || formatPhoneNumber(user?.login ?? '');
mentionDisplayText = getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, currentUserPersonalDetails, user?.login ?? '') ?? '';
navigationRoute = ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute());
} else if ('data' in tnode && !isEmptyObject(tnode.data)) {
Expand All @@ -56,9 +56,15 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
Str.removeSMSDomain(getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, currentUserPersonalDetails) ?? ''),
);

accountID = getAccountIDsByLogins([mentionDisplayText])?.at(0) ?? -1;
accountID = getAccountIDsByLogins([mentionDisplayText], false)?.at(0) ?? -1;
if (accountID !== -1) {
const user = personalDetails?.[accountID];
mentionDisplayText = getDisplayNameOrDefault(user) || formatPhoneNumber(user?.login ?? '');
mentionDisplayText = getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, currentUserPersonalDetails, user?.login ?? '') ?? '';
} else {
mentionDisplayText = Str.removeSMSDomain(mentionDisplayText);
}
navigationRoute = ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute(), mentionDisplayText);
mentionDisplayText = Str.removeSMSDomain(mentionDisplayText);
} else {
// If neither an account ID or email is provided, don't render anything
return null;
Expand Down Expand Up @@ -114,7 +120,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
testID="mention-user"
href={`/${navigationRoute}`}
>
{htmlAttribAccountID ? `@${mentionDisplayText}` : <TNodeChildrenRenderer tnode={tnodeClone ?? tnode} />}
{accountID && accountID !== -1 ? `@${mentionDisplayText}` : <TNodeChildrenRenderer tnode={tnodeClone ?? tnode} />}
</Text>
</UserDetailsTooltip>
</Text>
Expand Down
4 changes: 2 additions & 2 deletions src/libs/PersonalDetailsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ function getPersonalDetailByEmail(email: string): PersonalDetails | undefined {
* @param logins Array of user logins
* @returns Array of accountIDs according to passed logins
*/
function getAccountIDsByLogins(logins: string[]): number[] {
function getAccountIDsByLogins(logins: string[], shouldGenerateAccountID = true): number[] {
return logins.reduce<number[]>((foundAccountIDs, login) => {
const currentDetail = personalDetails.find((detail) => detail?.login === login?.toLowerCase());
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(generateAccountID(login));
foundAccountIDs.push(shouldGenerateAccountID ? generateAccountID(login) : -1);
} else {
foundAccountIDs.push(Number(currentDetail.accountID));
}
Expand Down
Loading