Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use oldPolicyName report field for archived workspace chats #8436

Merged
merged 37 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d6b2c65
Use oldPolicyName report field in ArchivedReportFooter
roryabraham Apr 1, 2022
e5b8028
Use oldPolicyName for ReportWelcomeMessage
roryabraham Apr 1, 2022
511fbf6
Use oldPolicyName in sidebar links too
roryabraham Apr 1, 2022
67ba2da
Add unit test for OptionsListUtils change
roryabraham Apr 1, 2022
8b59413
Merge branch 'main' into Rory-ArchivedPolicyName
roryabraham Apr 13, 2022
e0c5cc8
Merge branch 'main' into Rory-ArchivedPolicyName
roryabraham Apr 20, 2022
a477ed5
Revert outdated changes
roryabraham Apr 20, 2022
9e180a6
Use reportID prop instead of report.reportID
roryabraham Apr 21, 2022
1a56e03
Add utility function for getDisplayNamesWithTooltips to reportUtils
roryabraham Apr 21, 2022
a1672dd
Make ReportUtils capitalized to match other libs
roryabraham Apr 21, 2022
7238931
Use getDisplayNamesWithTooltips everywhere
roryabraham Apr 21, 2022
d04277f
Fix typo in pronouns
roryabraham Apr 21, 2022
1877d26
Add unit tests for getDisplayNamesWithTooltips
roryabraham Apr 21, 2022
6c362cc
Add ReportUtils.getTitle
roryabraham Apr 21, 2022
2076984
Add unit tests for getTitle
roryabraham Apr 21, 2022
3c744a5
Use getTitle in HeaderView
roryabraham Apr 21, 2022
4704ced
Merge branch 'main' into Rory-ArchivedPolicyName
roryabraham Apr 21, 2022
6defc76
Remove personalDetails subscription from ReportUtils and fix import c…
roryabraham Apr 21, 2022
9aed0a3
Safely access participants
roryabraham Apr 21, 2022
e47974a
Merge branch 'main' into Rory-ArchivedPolicyName
roryabraham Apr 21, 2022
76b6df2
Account for admin/member views
roryabraham Apr 21, 2022
49c4845
Fix double-archived bug
roryabraham Apr 21, 2022
92cb76b
Add better documentation for getPersonalDetailsForLogins return type
roryabraham Apr 21, 2022
9b23765
Fix JSDoc style
roryabraham Apr 21, 2022
7059036
Merge branch 'main' into Rory-ArchivedPolicyName
roryabraham Apr 22, 2022
4d559a8
Update JS formatting
roryabraham Apr 22, 2022
95fcc40
Merge branch 'main' into Rory-ArchivedPolicyName
roryabraham Apr 22, 2022
dc210f6
Rename getTitle to getReportName
roryabraham Apr 22, 2022
5c7bca7
Update tests to account for current user
roryabraham Apr 23, 2022
fa54389
Account for non-chat-reports
roryabraham Apr 23, 2022
fe02dc7
Make LoginUtils account for MERGED_1 and MERGED_2
roryabraham Apr 23, 2022
32a7c2c
Merge branch 'main' into Rory-ArchivedPolicyName
roryabraham May 5, 2022
f2a6559
Fix bad import
roryabraham May 5, 2022
4ed0a29
Switch useShortForm to shouldUseShortForm
roryabraham May 5, 2022
f9b304d
Revert changes in OptionsListUtilsTest
roryabraham May 5, 2022
83b6cc9
Fix JS crash
roryabraham May 5, 2022
58b9bd6
Merge branch 'main' into Rory-ArchivedPolicyName
roryabraham May 10, 2022
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
2 changes: 1 addition & 1 deletion src/components/ArchivedReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import withLocalize, {withLocalizePropTypes} from './withLocalize';
import compose from '../libs/compose';
import personalDetailsPropType from '../pages/personalDetailsPropType';
import ONYXKEYS from '../ONYXKEYS';
import * as ReportUtils from '../libs/reportUtils';
import * as ReportUtils from '../libs/ReportUtils';

const propTypes = {
/** The reason this report was archived */
Expand Down
18 changes: 3 additions & 15 deletions src/components/OptionRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
View,
StyleSheet,
} from 'react-native';
import Str from 'expensify-common/lib/str';
import styles from '../styles/styles';
import * as StyleUtils from '../styles/StyleUtils';
import optionPropTypes from './optionPropTypes';
Expand All @@ -23,6 +22,7 @@ import Text from './Text';
import SelectCircle from './SelectCircle';
import SubscriptAvatar from './SubscriptAvatar';
import CONST from '../CONST';
import * as ReportUtils from '../libs/ReportUtils';

const propTypes = {
/** Background Color of the Option Row */
Expand Down Expand Up @@ -113,21 +113,9 @@ const OptionRow = (props) => {
: props.backgroundColor;
const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor;
const isMultipleParticipant = lodashGet(props.option, 'participantsList.length', 0) > 1;
const displayNamesWithTooltips = _.map(

// We only create tooltips for the first 10 users or so since some reports have hundreds of users causing
// performance to degrade.
(props.option.participantsList || []).slice(0, 10),
({displayName, firstName, login}) => {
const displayNameTrimmed = Str.isSMSLogin(login) ? props.toLocalPhone(displayName) : displayName;

return {
displayName: (isMultipleParticipant ? firstName : displayNameTrimmed) || Str.removeSMSDomain(login),
tooltip: Str.removeSMSDomain(login),
};
},
);

// We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade.
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips((props.option.participantsList || []).slice(0, 10), isMultipleParticipant);
const avatarTooltips = props.showTitleTooltip && !props.option.isChatRoom && !props.option.isArchivedRoom ? _.pluck(displayNamesWithTooltips, 'tooltip') : undefined;

return (
Expand Down
24 changes: 3 additions & 21 deletions src/components/ReportWelcomeText.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import Str from 'expensify-common/lib/str';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import styles from '../styles/styles';
import Text from './Text';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import compose from '../libs/compose';
import * as ReportUtils from '../libs/reportUtils';
import * as ReportUtils from '../libs/ReportUtils';
import * as OptionsListUtils from '../libs/OptionsListUtils';
import ONYXKEYS from '../ONYXKEYS';
import CONST from '../CONST';

const personalDetailsPropTypes = PropTypes.shape({
/** The login of the person (either email or phone number) */
Expand Down Expand Up @@ -53,25 +51,9 @@ const ReportWelcomeText = (props) => {
const isDefault = !(isChatRoom || isPolicyExpenseChat);
const participants = lodashGet(props.report, 'participants', []);
const isMultipleParticipant = participants.length > 1;
const displayNamesWithTooltips = _.map(
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(
OptionsListUtils.getPersonalDetailsForLogins(participants, props.personalDetails),
({
displayName, firstName, login, pronouns,
}) => {
const longName = displayName || Str.removeSMSDomain(login);
const longNameLocalized = Str.isSMSLogin(longName) ? props.toLocalPhone(longName) : longName;
const shortName = firstName || longNameLocalized;
let finalPronouns = pronouns;
if (pronouns && pronouns.startsWith(CONST.PRONOUNS.PREFIX)) {
const localeKey = pronouns.replace(CONST.PRONOUNS.PREFIX, '');
finalPronouns = props.translate(`pronouns.${localeKey}`);
}
return {
displayName: isMultipleParticipant ? shortName : longNameLocalized,
tooltip: Str.removeSMSDomain(login),
pronouns: finalPronouns,
};
},
isMultipleParticipant,
);
const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(props.report, props.policies);
return (
Expand Down
2 changes: 1 addition & 1 deletion src/libs/LoginUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CONST from '../CONST';
* @returns {String}
*/
function getEmailWithoutMergedAccountPrefix(email) {
return email.replace(/^MERGED_0@/, '');
return email.replace(/^MERGED_\d@/, '');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a random fix, but this code makes it look like theoretically we could have MERGED_1 or MERGED_2

}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/MainDrawerNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Permissions from '../../Permissions';
import ReportScreen from '../../../pages/home/ReportScreen';
import SidebarScreen from '../../../pages/home/sidebar/SidebarScreen';
import BaseDrawerNavigator from './BaseDrawerNavigator';
import * as ReportUtils from '../../reportUtils';
import * as ReportUtils from '../../ReportUtils';

const propTypes = {
/** Available reports that would be displayed in this navigator */
Expand Down
19 changes: 10 additions & 9 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import lodashOrderBy from 'lodash/orderBy';
import Str from 'expensify-common/lib/str';
import ONYXKEYS from '../ONYXKEYS';
import CONST from '../CONST';
import * as ReportUtils from './reportUtils';
import * as ReportUtils from './ReportUtils';
import * as Localize from './Localize';
import Permissions from './Permissions';
import * as CollectionUtils from './CollectionUtils';
Expand Down Expand Up @@ -112,22 +112,22 @@ function addSMSDomainIfPhoneNumber(login) {
*
* @param {Array} logins
* @param {Object} personalDetails
* @returns {Array}
* @returns {Object} – keys of the object are emails, values are PersonalDetails objects.
*/
function getPersonalDetailsForLogins(logins, personalDetails) {
return _.map(logins, (login) => {
const personalDetailsForLogins = {};
_.each(logins, (login) => {
let personalDetail = personalDetails[login];

if (!personalDetail) {
personalDetail = {
login,
displayName: login,
avatar: ReportUtils.getDefaultAvatar(login),
};
}

return personalDetail;
personalDetailsForLogins[login] = personalDetail;
});
return personalDetailsForLogins;
}

/**
Expand Down Expand Up @@ -220,7 +220,7 @@ function createOption(logins, personalDetails, report, {
}) {
const isChatRoom = ReportUtils.isChatRoom(report);
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
const personalDetailList = getPersonalDetailsForLogins(logins, personalDetails);
const personalDetailList = _.values(getPersonalDetailsForLogins(logins, personalDetails));
const isArchivedRoom = ReportUtils.isArchivedRoom(report);
const hasMultipleParticipants = personalDetailList.length > 1 || isChatRoom || isPolicyExpenseChat;
const personalDetail = personalDetailList[0];
Expand All @@ -242,7 +242,7 @@ function createOption(logins, personalDetails, report, {
if (isPolicyExpenseChat && isArchivedRoom) {
const archiveReason = lodashGet(lastReportActions[report.reportID], 'originalMessage.reason', CONST.REPORT.ARCHIVE_REASON.DEFAULT);
lastMessageText = Localize.translate(preferredLocale, `reportArchiveReasons.${archiveReason}`, {
displayName: lastActorDetails.displayName,
displayName: lodashGet(lastActorDetails, 'displayName', report.lastActorEmail),
policyName: ReportUtils.getPolicyName(report, policies),
});
}
Expand All @@ -252,7 +252,8 @@ function createOption(logins, personalDetails, report, {
let text;
let alternateText;
if (isChatRoom || isPolicyExpenseChat) {
text = lodashGet(report, ['reportName'], '');
text = lodashGet(report, 'reportName')
|| lodashGet(report, 'oldPolicyName', '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Do archived room and "own policy expense chats" not have reportName?

Just wondering because the previous logic implies that if we have those types we'll use the oldPolicyName but don't really imply there's no reportName at all. We can't tell which things would have report names and others wouldn't.

Copy link
Contributor Author

@roryabraham roryabraham Apr 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question – this probably needs to be cleaned up. The reportName for archived "own PolicyExpenseChat" is just (archived), which surely will lead to unexpected behavior (such as the sidebar bug I am seeing). I think if we update this to make sure the reportName is correct in Onyx, then we could just use that here directly instead of oldPolicyName.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of overlap between getChatReportName and ReportUtils.getTitle.

I think I'll refactor this to:

  1. Rename ReportUtils.getTitle to ReportUtils.getReportName.
  2. Add more unit tests for ReportUtils.getReportName to add separate tests for user-created policy rooms and default policy rooms.
  3. Refactor things to eliminate getChatReportName and use ReportUtils.getReportName instead.
  4. In the UI, just reference the reportName in Onyx directly instead of using ReportUtils.getReportName.

Does that sound like a good plan?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure the reportName is correct in Onyx, then we could just use that here directly instead of oldPolicyName

That makes sense to me. But I also curious if we can provide the correct reportName via the server. Why do these reports have names that are not the actual name we want to show... 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I also curious if we can provide the correct reportName via the server. Why do these reports have names that are not the actual name we want to show

So I did a fair amount of research into what it would look like to generate the reportName for chat reports via the server, and I don't think it's a good idea. Report titles are generated from a variety of sources / pieces of information:

  • The report itself
  • Who is looking at the report? (admin view of workspace chat is the employee name, member view is the policy name)
    • Because the title is different depending on who's looking at it, we can't really save the correct report name in the database.
  • personal details
  • policies

The server can do all the logic to generate the correct title using information from the current user, report, policy, and personalDetails. But if we do that we lose all the benefits of "live" Pusher data.
- i.e: if report titles are generated only on the server and a report participant updates their personal details, you would only see that change if you refresh the page or fetch the report again.
- If report titles are generated on the front-end, then you would see that changes as soon as the personal details for that user update (currently we don't have a Pusher channel for personal details, but hopefully we will soon).

Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly kept going back and forth on this, so I posted in slack here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circling back on this, we determined that we should generate report titles on the client. Furthermore, since the value is a composite of several server-generated values that can be set up with Pusher, I don't want to save the composite value in Onyx.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it all makes sense. I guess a counter to the approach is that if the server is supposed to be pushing changes directly to Onyx (a la Optimized API) then maybe a change to personal details could also send out updates about report names. But doesn't seem like there is a ton of clear value in doing that.

alternateText = (showChatPreviewLine && !forcePolicyNamePreview && lastMessageText)
? lastMessageText
: subtitle;
Expand Down
104 changes: 104 additions & 0 deletions src/libs/reportUtils.js → src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Onyx from 'react-native-onyx';
import ONYXKEYS from '../ONYXKEYS';
import CONST from '../CONST';
import * as Localize from './Localize';
import * as LocalePhoneNumber from './LocalePhoneNumber';
import * as Expensicons from '../components/Icon/Expensicons';
import md5 from './md5';

Expand All @@ -14,6 +15,17 @@ Onyx.connect({
callback: val => sessionEmail = val ? val.email : null,
});

let preferredLocale = CONST.DEFAULT_LOCALE;
Onyx.connect({
key: ONYXKEYS.NVP_PREFERRED_LOCALE,
callback: (val) => {
if (!val) {
return;
}
preferredLocale = val;
},
});

/**
* Returns the concatenated title for the PrimaryLogins of a report
*
Expand Down Expand Up @@ -363,6 +375,96 @@ function getIcons(report, personalDetails, policies, defaultIcon = null) {
return _.map(sortedParticipants, item => item.avatar);
}

/**
* Get the displayName for a single report participant.
*
* @param {Object} participant
* @param {String} participant.displayName
* @param {String} participant.firstName
* @param {String} participant.login
* @param {Boolean} [shouldUseShortForm]
* @returns {String}
*/
function getDisplayNameForParticipant(participant, shouldUseShortForm = false) {
if (!participant) {
return '';
}

const loginWithoutSMSDomain = Str.removeSMSDomain(participant.login);
let longName = participant.displayName || loginWithoutSMSDomain;
if (Str.isSMSLogin(longName)) {
longName = LocalePhoneNumber.toLocalPhone(preferredLocale, longName);
}
const shortName = participant.firstName || longName;

return shouldUseShortForm ? shortName : longName;
}

/**
* @param {Object} participants
* @param {Boolean} isMultipleParticipantReport
* @returns {Array}
*/
function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport) {
return _.map(participants, (participant) => {
const displayName = getDisplayNameForParticipant(participant, isMultipleParticipantReport);
const tooltip = Str.removeSMSDomain(participant.login);

let pronouns = participant.pronouns;
if (pronouns && pronouns.startsWith(CONST.PRONOUNS.PREFIX)) {
const pronounTranslationKey = pronouns.replace(CONST.PRONOUNS.PREFIX, '');
pronouns = Localize.translateLocal(`pronouns.${pronounTranslationKey}`);
}

return {
displayName,
tooltip,
pronouns,
};
});
}

/**
* Get the title for a report.
*
* @param {Object} report
* @param {Object} [personalDetailsForParticipants]
* @param {Object} [policies]
* @returns {String}
*/
function getReportName(report, personalDetailsForParticipants = {}, policies = {}) {
if (lodashGet(report, 'reportNameValuePairs.type') !== 'chat') {
return report.reportName || '';
}

let formattedName;
if (isChatRoom(report)) {
formattedName = `#${report.reportName}`;
}

if (isPolicyExpenseChat(report)) {
const reportOwnerPersonalDetails = lodashGet(personalDetailsForParticipants, report.ownerEmail);
const reportOwnerDisplayName = getDisplayNameForParticipant(reportOwnerPersonalDetails) || report.reportName;
formattedName = report.isOwnPolicyExpenseChat ? getPolicyName(report, policies) : reportOwnerDisplayName;
}

if (isArchivedRoom(report)) {
formattedName += ` (${Localize.translateLocal('common.archived')})`;
}

if (formattedName) {
return formattedName;
}

// Not a room or PolicyExpenseChat, generate title from participants
const participants = _.without(lodashGet(report, 'participants', []), sessionEmail);
const displayNamesWithTooltips = getDisplayNamesWithTooltips(
_.isEmpty(personalDetailsForParticipants) ? participants : personalDetailsForParticipants,
participants.length > 1,
);
return _.map(displayNamesWithTooltips, ({displayName}) => displayName).join(', ');
}

export {
getReportParticipantsTitle,
isReportMessageAttachment,
Expand All @@ -387,4 +489,6 @@ export {
getDefaultAvatar,
getIcons,
getRoomWelcomeMessage,
getDisplayNamesWithTooltips,
getReportName,
};
2 changes: 1 addition & 1 deletion src/libs/actions/PersonalDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import CONST from '../../CONST';
import * as API from '../API';
import NameValuePair from './NameValuePair';
import * as LoginUtils from '../LoginUtils';
import * as ReportUtils from '../reportUtils';
import * as ReportUtils from '../ReportUtils';
import Growl from '../Growl';
import * as Localize from '../Localize';
import Timing from './Timing';
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import CONFIG from '../../CONFIG';
import CONST from '../../CONST';
import Log from '../Log';
import * as LoginUtils from '../LoginUtils';
import * as ReportUtils from '../reportUtils';
import * as ReportUtils from '../ReportUtils';
import Timers from '../Timers';
import * as ReportActions from './ReportActions';
import Growl from '../Growl';
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/ReportActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import lodashGet from 'lodash/get';
import ONYXKEYS from '../../ONYXKEYS';
import * as CollectionUtils from '../CollectionUtils';
import CONST from '../../CONST';
import * as ReportUtils from '../reportUtils';
import * as ReportUtils from '../ReportUtils';
import * as ReportActionsUtils from '../ReportActionsUtils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Onyx from 'react-native-onyx';
import _ from 'underscore';
import lodashGet from 'lodash/get';
import Navigation from '../Navigation/Navigation';
import * as ReportUtils from '../reportUtils';
import * as ReportUtils from '../ReportUtils';
import ROUTES from '../../ROUTES';
import * as Policy from './Policy';
import ONYXKEYS from '../../ONYXKEYS';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import compose from '../libs/compose';
import CommunicationsLink from '../components/CommunicationsLink';
import Tooltip from '../components/Tooltip';
import CONST from '../CONST';
import * as ReportUtils from '../libs/reportUtils';
import * as ReportUtils from '../libs/ReportUtils';
import DateUtils from '../libs/DateUtils';
import * as Expensicons from '../components/Icon/Expensicons';
import MenuItem from '../components/MenuItem';
Expand Down
14 changes: 3 additions & 11 deletions src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import Str from 'expensify-common/lib/str';
import _ from 'underscore';
import {View, ScrollView} from 'react-native';
import lodashGet from 'lodash/get';
Expand All @@ -15,7 +14,7 @@ import HeaderWithCloseButton from '../components/HeaderWithCloseButton';
import styles from '../styles/styles';
import DisplayNames from '../components/DisplayNames';
import * as OptionsListUtils from '../libs/OptionsListUtils';
import * as ReportUtils from '../libs/reportUtils';
import * as ReportUtils from '../libs/ReportUtils';
import participantPropTypes from '../components/participantPropTypes';
import * as Expensicons from '../components/Icon/Expensicons';
import ROUTES from '../ROUTES';
Expand Down Expand Up @@ -108,16 +107,9 @@ class ReportDetailsPage extends Component {
const chatRoomSubtitle = ReportUtils.getChatRoomSubtitle(this.props.report, this.props.policies);
const participants = lodashGet(this.props.report, 'participants', []);
const isMultipleParticipant = participants.length > 1;
const displayNamesWithTooltips = _.map(
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(
OptionsListUtils.getPersonalDetailsForLogins(participants, this.props.personalDetails),
({displayName, firstName, login}) => {
const displayNameTrimmed = Str.isSMSLogin(login) ? this.props.toLocalPhone(displayName) : displayName;

return {
displayName: (isMultipleParticipant ? firstName : displayNameTrimmed) || Str.removeSMSDomain(login),
tooltip: Str.removeSMSDomain(login),
};
},
isMultipleParticipant,
);
return (
<ScreenWrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReportParticipantsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ROUTES from '../ROUTES';
import personalDetailsPropType from './personalDetailsPropType';
import withLocalize, {withLocalizePropTypes} from '../components/withLocalize';
import compose from '../libs/compose';
import * as ReportUtils from '../libs/reportUtils';
import * as ReportUtils from '../libs/ReportUtils';

const propTypes = {
/* Onyx Props */
Expand Down
Loading