From 25a0621b657c22969752f0161e1a00793cf47c7a Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 29 Feb 2024 20:16:36 +0300 Subject: [PATCH 1/9] remove sms domain from phone mention --- package-lock.json | 6 +++--- package.json | 2 +- .../HTMLRenderers/MentionUserRenderer.tsx | 6 ++++-- src/pages/DetailsPage.tsx | 2 +- src/pages/ProfilePage.js | 2 +- .../home/report/ReportActionCompose/SuggestionMention.tsx | 6 ++++-- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 066c140d915f..677e6b6dc02c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,7 +52,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#83ae6194b3e4feb363ea9d061085a7ab76e35ffb", + "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#ee0f33865e3a27245e5cf01ed0c62cf88d44bb10", "expo": "^50.0.3", "expo-av": "~13.10.4", "expo-image": "1.10.1", @@ -30758,8 +30758,8 @@ }, "node_modules/expensify-common": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#83ae6194b3e4feb363ea9d061085a7ab76e35ffb", - "integrity": "sha512-nAe0fPbfRn/VYHe6mCp/APmMbda/NiHE3aZq7q0kWhPmz1LVTukeaREmZ7SN8auyLOy9/mS0RIQLeV0AR8vsrA==", + "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#ee0f33865e3a27245e5cf01ed0c62cf88d44bb10", + "integrity": "sha512-1w2PmSG12JxHxG6hYfBrGoJz3WqQGI9QgTVmRb9lDdy482ZH6ZtgOR8LURlPB0x6FjT+IKs6zbKQqE1eNXzE/g==", "license": "MIT", "dependencies": { "classnames": "2.4.0", diff --git a/package.json b/package.json index 10b4f107aa9d..781ff60927d6 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#83ae6194b3e4feb363ea9d061085a7ab76e35ffb", + "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#ee0f33865e3a27245e5cf01ed0c62cf88d44bb10", "expo": "^50.0.3", "expo-av": "~13.10.4", "expo-image": "1.10.1", diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index 5d8c0f6ef81e..6520cfa2d876 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -1,3 +1,4 @@ +import Str from 'expensify-common/lib/str'; import cloneDeep from 'lodash/cloneDeep'; import isEmpty from 'lodash/isEmpty'; import React from 'react'; @@ -59,16 +60,17 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona const user = personalDetails[htmlAttribAccountID]; accountID = parseInt(htmlAttribAccountID, 10); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - displayNameOrLogin = PersonalDetailsUtils.getDisplayNameOrDefault(user, LocalePhoneNumber.formatPhoneNumber(user?.login ?? '')); + displayNameOrLogin = Str.removeSMSDomain(PersonalDetailsUtils.getDisplayNameOrDefault(user, LocalePhoneNumber.formatPhoneNumber(user?.login ?? ''))); navigationRoute = ROUTES.PROFILE.getRoute(htmlAttribAccountID); } else if ('data' in tnodeClone && !isEmptyObject(tnodeClone.data)) { // We need to remove the LTR unicode and leading @ from data as it is not part of the login displayNameOrLogin = tnodeClone.data.replace(CONST.UNICODE.LTR, '').slice(1); // We need to replace tnode.data here because we will pass it to TNodeChildrenRenderer below - asMutable(tnodeClone).data = tnodeClone.data.replace(displayNameOrLogin, getMentionDisplayText(displayNameOrLogin, htmlAttributeAccountID)); + asMutable(tnodeClone).data = tnodeClone.data.replace(displayNameOrLogin, Str.removeSMSDomain(getMentionDisplayText(displayNameOrLogin, htmlAttributeAccountID))); accountID = PersonalDetailsUtils.getAccountIDsByLogins([displayNameOrLogin])?.[0]; navigationRoute = ROUTES.DETAILS.getRoute(displayNameOrLogin); + displayNameOrLogin = Str.removeSMSDomain(displayNameOrLogin); } else { // If neither an account ID or email is provided, don't render anything return null; diff --git a/src/pages/DetailsPage.tsx b/src/pages/DetailsPage.tsx index a9adb5310e58..4d74b87eac79 100755 --- a/src/pages/DetailsPage.tsx +++ b/src/pages/DetailsPage.tsx @@ -128,7 +128,7 @@ function DetailsPage({personalDetails, route, session}: DetailsPageProps) { style={[styles.textHeadline, styles.mb6, styles.pre]} numberOfLines={1} > - {displayName} + {formatPhoneNumber(displayName)} )} {details.login ? ( diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 0b986adf1c6f..5c64e8dbfe47 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -172,7 +172,7 @@ function ProfilePage(props) { style={[styles.textHeadline, styles.pre, styles.mb6, styles.w100, styles.textAlignCenter]} numberOfLines={1} > - {displayName} + {props.formatPhoneNumber(displayName)} )} {hasStatus && ( diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index ac52c06ee084..1930b7daaa1d 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -1,3 +1,4 @@ +import Str from 'expensify-common/lib/str'; import lodashSortBy from 'lodash/sortBy'; import type {ForwardedRef} from 'react'; import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState} from 'react'; @@ -62,7 +63,8 @@ function SuggestionMention( (highlightedMentionIndexInner: number) => { const commentBeforeAtSign = value.slice(0, suggestionValues.atSignIndex); const mentionObject = suggestionValues.suggestedMentions[highlightedMentionIndexInner]; - const mentionCode = mentionObject.text === CONST.AUTO_COMPLETE_SUGGESTER.HERE_TEXT ? CONST.AUTO_COMPLETE_SUGGESTER.HERE_TEXT : `@${mentionObject.login}`; + const mentionCode = + mentionObject.text === CONST.AUTO_COMPLETE_SUGGESTER.HERE_TEXT ? CONST.AUTO_COMPLETE_SUGGESTER.HERE_TEXT : `@${Str.removeSMSDomain(mentionObject.login ?? '')}`; const commentAfterMention = value.slice(suggestionValues.atSignIndex + suggestionValues.mentionPrefix.length + 1); updateComment(`${commentBeforeAtSign}${mentionCode} ${SuggestionsUtils.trimLeadingSpace(commentAfterMention)}`, true); @@ -151,7 +153,7 @@ function SuggestionMention( const sortedPersonalDetails = lodashSortBy(filteredPersonalDetails, (detail) => detail?.displayName || detail?.login); sortedPersonalDetails.slice(0, CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_SUGGESTIONS - suggestions.length).forEach((detail) => { suggestions.push({ - text: PersonalDetailsUtils.getDisplayNameOrDefault(detail), + text: formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(detail)), alternateText: formatPhoneNumber(detail?.login ?? ''), login: detail?.login, icons: [ From 8765e9fdefe97e70a1756bc0e3a2ed7523aa72aa Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 29 Feb 2024 20:19:07 +0300 Subject: [PATCH 2/9] remove sms domain from display name --- src/pages/home/report/ReportActionCompose/SuggestionMention.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index 1930b7daaa1d..fc0a2f9b6da1 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -153,7 +153,7 @@ function SuggestionMention( const sortedPersonalDetails = lodashSortBy(filteredPersonalDetails, (detail) => detail?.displayName || detail?.login); sortedPersonalDetails.slice(0, CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_SUGGESTIONS - suggestions.length).forEach((detail) => { suggestions.push({ - text: formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(detail)), + text: Str.removeSMSDomain(PersonalDetailsUtils.getDisplayNameOrDefault(detail)), alternateText: formatPhoneNumber(detail?.login ?? ''), login: detail?.login, icons: [ From f7da703d332efca17e8bc5f5cf7e2d791f1ce4fa Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 29 Feb 2024 20:25:04 +0300 Subject: [PATCH 3/9] remove the domain from tooltip text --- .../UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx b/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx index 592cec3beca5..72df60f9d39b 100644 --- a/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx +++ b/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx @@ -36,7 +36,7 @@ function BaseUserDetailsTooltip({accountID, fallbackUserDetails, icon, delegateA userAccountID = delegateAccountID; } - let title = String(userDisplayName).trim() ? userDisplayName : ''; + let title = String(userDisplayName).trim() ? Str.removeSMSDomain(userDisplayName) : ''; let subtitle = userLogin.trim() && LocalePhoneNumber.formatPhoneNumber(userLogin) !== userDisplayName ? Str.removeSMSDomain(userLogin) : ''; if (icon && (icon.type === CONST.ICON_TYPE_WORKSPACE || !title)) { title = icon.name ?? ''; From 28f2bdf414d2c7def14b36bb373bb9dc828d6a54 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 29 Feb 2024 21:18:34 +0300 Subject: [PATCH 4/9] format the tooltip text --- .../UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx b/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx index 72df60f9d39b..248b981a9424 100644 --- a/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx +++ b/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx @@ -36,7 +36,7 @@ function BaseUserDetailsTooltip({accountID, fallbackUserDetails, icon, delegateA userAccountID = delegateAccountID; } - let title = String(userDisplayName).trim() ? Str.removeSMSDomain(userDisplayName) : ''; + let title = String(userDisplayName).trim() ? LocalePhoneNumber.formatPhoneNumber(userDisplayName) : ''; let subtitle = userLogin.trim() && LocalePhoneNumber.formatPhoneNumber(userLogin) !== userDisplayName ? Str.removeSMSDomain(userLogin) : ''; if (icon && (icon.type === CONST.ICON_TYPE_WORKSPACE || !title)) { title = icon.name ?? ''; From 1e0e468a60b002d68073286fbcdef30c7f660228 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 29 Feb 2024 22:22:16 +0300 Subject: [PATCH 5/9] format phone number on message menu --- src/pages/DetailsPage.tsx | 2 +- src/pages/ProfilePage.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/DetailsPage.tsx b/src/pages/DetailsPage.tsx index 4d74b87eac79..dae9aeb4985f 100755 --- a/src/pages/DetailsPage.tsx +++ b/src/pages/DetailsPage.tsx @@ -161,7 +161,7 @@ function DetailsPage({personalDetails, route, session}: DetailsPageProps) { {!isCurrentUser && ( Report.navigateToAndOpenReport([login])} diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 5c64e8dbfe47..2e2d1cdefad1 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -226,7 +226,7 @@ function ProfilePage(props) { )} {!isCurrentUser && !Session.isAnonymousUser() && ( Report.navigateToAndOpenReportWithAccountIDs([accountID])} From d61c7ae85436cbe1e506d5062d4bdcc61c592482 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 6 Mar 2024 15:12:37 +0300 Subject: [PATCH 6/9] fix package lock json --- package-lock.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index b786a87320fb..1b967ea68af8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30977,13 +30977,8 @@ }, "node_modules/expensify-common": { "version": "1.0.0", -<<<<<<< HEAD "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#ee0f33865e3a27245e5cf01ed0c62cf88d44bb10", "integrity": "sha512-1w2PmSG12JxHxG6hYfBrGoJz3WqQGI9QgTVmRb9lDdy482ZH6ZtgOR8LURlPB0x6FjT+IKs6zbKQqE1eNXzE/g==", -======= - "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#a8ed0f8e1be3a1e09016e07a74cfd13c85bbc167", - "integrity": "sha512-3d/JHWgeS+LFPRahCAXdLwnBYQk4XUYybtgCm7VsdmMDtCeGUTksLsEY7F1Zqm+ULqZjmCtYwAi8IPKy0fsSOw==", ->>>>>>> main "license": "MIT", "dependencies": { "classnames": "2.5.0", From 4298e4d0156bf95aebbf9f11f34ce92896a5e3ff Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 6 Mar 2024 16:47:25 +0300 Subject: [PATCH 7/9] remove sms domain from display names --- .../HTMLRenderers/MentionUserRenderer.tsx | 2 +- .../UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx | 2 +- src/libs/PersonalDetailsUtils.ts | 7 +++++++ src/libs/SidebarUtils.ts | 3 ++- src/pages/DetailsPage.tsx | 4 ++-- src/pages/ProfilePage.js | 4 ++-- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index 6520cfa2d876..0327b6bc6f56 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -60,7 +60,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona const user = personalDetails[htmlAttribAccountID]; accountID = parseInt(htmlAttribAccountID, 10); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - displayNameOrLogin = Str.removeSMSDomain(PersonalDetailsUtils.getDisplayNameOrDefault(user, LocalePhoneNumber.formatPhoneNumber(user?.login ?? ''))); + displayNameOrLogin = PersonalDetailsUtils.getDisplayNameOrDefault(user, LocalePhoneNumber.formatPhoneNumber(user?.login ?? '')); navigationRoute = ROUTES.PROFILE.getRoute(htmlAttribAccountID); } else if ('data' in tnodeClone && !isEmptyObject(tnodeClone.data)) { // We need to remove the LTR unicode and leading @ from data as it is not part of the login diff --git a/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx b/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx index 248b981a9424..592cec3beca5 100644 --- a/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx +++ b/src/components/UserDetailsTooltip/BaseUserDetailsTooltip/index.tsx @@ -36,7 +36,7 @@ function BaseUserDetailsTooltip({accountID, fallbackUserDetails, icon, delegateA userAccountID = delegateAccountID; } - let title = String(userDisplayName).trim() ? LocalePhoneNumber.formatPhoneNumber(userDisplayName) : ''; + let title = String(userDisplayName).trim() ? userDisplayName : ''; let subtitle = userLogin.trim() && LocalePhoneNumber.formatPhoneNumber(userLogin) !== userDisplayName ? Str.removeSMSDomain(userLogin) : ''; if (icon && (icon.type === CONST.ICON_TYPE_WORKSPACE || !title)) { title = icon.name ?? ''; diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 9dd60eeebcef..65aadd440010 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -26,6 +26,13 @@ Onyx.connect({ function getDisplayNameOrDefault(passedPersonalDetails?: Partial | null, defaultValue = '', shouldFallbackToHidden = true, shouldAddCurrentUserPostfix = false): string { let displayName = passedPersonalDetails?.displayName ? passedPersonalDetails.displayName.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '') : ''; + + // If the displayName is not set by the user, the backend sets the diplayName same as the login so + // we need to remove the sms domain from the displayName if it is an sms login. + if (displayName === passedPersonalDetails?.login && Str.isSMSLogin(passedPersonalDetails?.login)) { + displayName = Str.removeSMSDomain(displayName); + } + if (shouldAddCurrentUserPostfix && !!displayName) { displayName = `${displayName} (${Localize.translateLocal('common.you').toLowerCase()})`; } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 8d53e992cb2d..dcb28e4e32c1 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -316,7 +316,8 @@ function getOptionData({ const lastActorDisplayName = OptionsListUtils.getLastActorDisplayName(lastActorDetails, hasMultipleParticipants); const lastMessageTextFromReport = OptionsListUtils.getLastMessageTextForReport(report, lastActorDetails, policy); - let lastMessageText = lastMessageTextFromReport; + // We need to remove sms domain in case the last message text has a phone number mention with sms domain. + let lastMessageText = Str.removeSMSDomain(lastMessageTextFromReport); const lastAction = visibleReportActionItems[report.reportID]; diff --git a/src/pages/DetailsPage.tsx b/src/pages/DetailsPage.tsx index dae9aeb4985f..a9adb5310e58 100755 --- a/src/pages/DetailsPage.tsx +++ b/src/pages/DetailsPage.tsx @@ -128,7 +128,7 @@ function DetailsPage({personalDetails, route, session}: DetailsPageProps) { style={[styles.textHeadline, styles.mb6, styles.pre]} numberOfLines={1} > - {formatPhoneNumber(displayName)} + {displayName} )} {details.login ? ( @@ -161,7 +161,7 @@ function DetailsPage({personalDetails, route, session}: DetailsPageProps) { {!isCurrentUser && ( Report.navigateToAndOpenReport([login])} diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 1d902409690d..a4c740250908 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -172,7 +172,7 @@ function ProfilePage(props) { style={[styles.textHeadline, styles.pre, styles.mb6, styles.w100, styles.textAlignCenter]} numberOfLines={1} > - {props.formatPhoneNumber(displayName)} + {displayName} )} {hasStatus && ( @@ -226,7 +226,7 @@ function ProfilePage(props) { )} {!isCurrentUser && !Session.isAnonymousUser() && ( Report.navigateToAndOpenReportWithAccountIDs([accountID])} From 8d4b777369f180753b1641ea2185dde3d8afb30c Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 6 Mar 2024 19:33:22 +0300 Subject: [PATCH 8/9] remove sms from user list item --- src/components/SelectionList/UserListItem.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/SelectionList/UserListItem.tsx b/src/components/SelectionList/UserListItem.tsx index 4619a2e54f74..71a6bf733cfb 100644 --- a/src/components/SelectionList/UserListItem.tsx +++ b/src/components/SelectionList/UserListItem.tsx @@ -1,3 +1,4 @@ +import Str from 'expensify-common/lib/str'; import React from 'react'; import {View} from 'react-native'; import MultipleAvatars from '@components/MultipleAvatars'; @@ -81,7 +82,7 @@ function UserListItem({ )} From 1c5ed545159a930dd54c63a10d67dc8875a68be6 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 7 Mar 2024 17:15:30 +0300 Subject: [PATCH 9/9] add null checker --- src/components/SelectionList/UserListItem.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/SelectionList/UserListItem.tsx b/src/components/SelectionList/UserListItem.tsx index 71a6bf733cfb..1fdcd36236ac 100644 --- a/src/components/SelectionList/UserListItem.tsx +++ b/src/components/SelectionList/UserListItem.tsx @@ -82,7 +82,7 @@ function UserListItem({ )}