diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 764699947a97..a384d5e54b9f 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -577,6 +577,16 @@ function isDM(report) { return !getChatType(report); } +/** + * Returns true if report has a single participant. + * + * @param {Object} report + * @returns {Boolean} + */ +function hasSingleParticipant(report) { + return report.participants && report.participants.length === 1; +} + /** * If the report is a thread and has a chat type set, it is a workspace chat. * @@ -2398,6 +2408,7 @@ function getMoneyRequestOptions(report, reportParticipants, betas) { const participants = _.filter(reportParticipants, (accountID) => currentUserPersonalDetails.accountID !== accountID); const hasExcludedIOUAccountIDs = lodashIntersection(reportParticipants, CONST.EXPENSIFY_ACCOUNT_IDS).length > 0; + const hasSingleParticipantInReport = participants.length === 1; const hasMultipleParticipants = participants.length > 1; if (hasExcludedIOUAccountIDs || (participants.length === 0 && !report.isOwnPolicyExpenseChat)) { @@ -2423,7 +2434,7 @@ function getMoneyRequestOptions(report, reportParticipants, betas) { ...(canRequestMoney(report) ? [CONST.IOU.MONEY_REQUEST_TYPE.REQUEST] : []), // Send money option should be visible only in DMs - ...(Permissions.canUseIOUSend(betas) && isChatReport(report) && !isPolicyExpenseChat(report) && participants.length === 1 ? [CONST.IOU.MONEY_REQUEST_TYPE.SEND] : []), + ...(Permissions.canUseIOUSend(betas) && isChatReport(report) && !isPolicyExpenseChat(report) && hasSingleParticipantInReport ? [CONST.IOU.MONEY_REQUEST_TYPE.SEND] : []), ]; } @@ -2711,6 +2722,8 @@ export { getOriginalReportID, canAccessReport, getReportOfflinePendingActionAndErrors, + isDM, getPolicy, shouldDisableRename, + hasSingleParticipant, }; diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index b3dd76a38d78..32ffa759fa16 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -13,6 +13,7 @@ import * as UserUtils from '../UserUtils'; import * as ErrorUtils from '../ErrorUtils'; import * as ReportActionsUtils from '../ReportActionsUtils'; import * as Expensicons from '../../components/Icon/Expensicons'; +import * as LocalePhoneNumber from '../LocalePhoneNumber'; let currentUserEmail; let currentUserAccountID; @@ -597,10 +598,16 @@ function getAssignee(details) { * */ function getShareDestination(reportID, reports, personalDetails) { const report = lodashGet(reports, `report_${reportID}`, {}); + let subtitle = ''; + if (ReportUtils.isChatReport(report) && ReportUtils.isDM(report) && ReportUtils.hasSingleParticipant(report)) { + subtitle = LocalePhoneNumber.formatPhoneNumber(report.participants[0]); + } else { + subtitle = ReportUtils.getChatRoomSubtitle(report); + } return { icons: ReportUtils.getIcons(report, personalDetails, Expensicons.FallbackAvatar, ReportUtils.isIOUReport(report)), displayName: ReportUtils.getReportName(report), - subtitle: ReportUtils.getChatRoomSubtitle(report), + subtitle, }; } diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index bc8cf0fed584..7622a0e73f18 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -91,8 +91,8 @@ function HeaderView(props) { const title = ReportUtils.getReportName(reportHeaderData); const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData); const parentNavigationSubtitle = ReportUtils.getParentNavigationSubtitle(reportHeaderData); - const isConcierge = participants.length === 1 && _.contains(participants, CONST.ACCOUNT_ID.CONCIERGE); - const isAutomatedExpensifyAccount = participants.length === 1 && ReportUtils.hasAutomatedExpensifyAccountIDs(participants); + const isConcierge = ReportUtils.hasSingleParticipant(props.report) && _.contains(participants, CONST.ACCOUNT_ID.CONCIERGE); + const isAutomatedExpensifyAccount = ReportUtils.hasSingleParticipant(props.report) && ReportUtils.hasAutomatedExpensifyAccountIDs(participants); const guideCalendarLink = lodashGet(props.account, 'guideCalendarLink'); // We hide the button when we are chatting with an automated Expensify account since it's not possible to contact