diff --git a/src/components/AvatarWithDisplayName.js b/src/components/AvatarWithDisplayName.js index 76155e1e9ff3..7889dcb0b703 100644 --- a/src/components/AvatarWithDisplayName.js +++ b/src/components/AvatarWithDisplayName.js @@ -50,12 +50,12 @@ const defaultProps = { }; function AvatarWithDisplayName(props) { - const title = props.isAnonymous ? props.report.displayName : ReportUtils.getDisplayNameForParticipant(props.report.ownerEmail, true); + const title = props.isAnonymous ? props.report.displayName : ReportUtils.getDisplayNameForParticipant(props.report.ownerAccountID, true); const subtitle = ReportUtils.getChatRoomSubtitle(props.report); const isExpenseReport = ReportUtils.isExpenseReport(props.report); const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies); const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs([props.report.ownerAccountID], props.personalDetails); - const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(ownerPersonalDetails, false); + const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(_.values(ownerPersonalDetails), false); const avatarContainerStyle = StyleUtils.getEmptyAvatarStyle(props.size) || styles.emptyAvatar; return ( diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js index 6ac373378e79..4292f3616be7 100644 --- a/src/components/ReportActionItem/IOUPreview.js +++ b/src/components/ReportActionItem/IOUPreview.js @@ -89,7 +89,7 @@ const propTypes = { personalDetails: PropTypes.objectOf( PropTypes.shape({ /** This is either the user's full name, or their login if full name is an empty string */ - displayName: PropTypes.string.isRequired, + displayName: PropTypes.string, }), ), diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 8a7392acfc8c..49f04b64657b 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -832,6 +832,7 @@ function getAccountIDForLogin(login) { /** * Get the displayName for a single report participant. + * Defaults to login if no display name is set. * * @param {Number} accountID * @param {Boolean} [shouldUseShortForm] @@ -842,7 +843,7 @@ function getDisplayNameForParticipant(accountID, shouldUseShortForm = false) { return ''; } const personalDetails = getPersonalDetailsForAccountID(accountID); - const longName = personalDetails.displayName; + const longName = personalDetails.displayName || (personalDetails.login && Str.removeSMSDomain(personalDetails.login)); const shortName = personalDetails.firstName || longName; return shouldUseShortForm ? shortName : longName; }