Skip to content
15 changes: 14 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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)) {
Expand All @@ -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] : []),
];
}

Expand Down Expand Up @@ -2711,6 +2722,8 @@ export {
getOriginalReportID,
canAccessReport,
getReportOfflinePendingActionAndErrors,
isDM,
getPolicy,
shouldDisableRename,
hasSingleParticipant,
};
9 changes: 8 additions & 1 deletion src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down