Skip to content

Commit

Permalink
Merge pull request #18880 from Expensify/stites-fixThreadHeader
Browse files Browse the repository at this point in the history
Fix header/lhn for threads
  • Loading branch information
chiragsalian authored May 15, 2023
2 parents 5b6c8ce + 423ec9a commit da8c1c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/AvatarWithDisplayName.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const defaultProps = {

const AvatarWithDisplayName = (props) => {
const title = ReportUtils.getDisplayNameForParticipant(props.report.ownerEmail, true);
const subtitle = ReportUtils.getChatRoomSubtitle(props.report, props.policies);
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.getPersonalDetailsForLogins([props.report.ownerEmail], props.personalDetails);
Expand Down
13 changes: 11 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,26 @@ function isThreadFirstChat(reportAction, reportID) {
/**
* Get either the policyName or domainName the chat is tied to
* @param {Object} report
* @param {Object} parentReport
* @returns {String}
*/
function getChatRoomSubtitle(report) {
function getChatRoomSubtitle(report, parentReport = null) {
if (isThread(report)) {
if (!getChatType(report)) {
return '';
}

// If thread is not from a DM or group chat, the subtitle will follow the pattern 'Workspace Name • #roomName'
const workspaceName = getPolicyName(report);
const roomName = isChatRoom(report) ? lodashGet(report, 'displayName') : '';
let roomName = '';
if (isChatRoom(report)) {
if (parentReport) {
roomName = lodashGet(parentReport, 'displayName', '');
} else {
roomName = lodashGet(report, 'displayName', '');
}
}

return [workspaceName, roomName].join(' • ');
}
if (!isDefaultRoom(report) && !isUserCreatedPolicyRoom(report) && !isPolicyExpenseChat(report)) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function getOptionData(reportID) {

const parentReport = result.parentReportID ? chatReports[`${ONYXKEYS.COLLECTION.REPORT}${result.parentReportID}`] : null;
const hasMultipleParticipants = participantPersonalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat;
const subtitle = ReportUtils.getChatRoomSubtitle(report);
const subtitle = ReportUtils.getChatRoomSubtitle(report, parentReport);

const login = Str.removeSMSDomain(lodashGet(personalDetail, 'login', ''));
const formattedLogin = Str.isSMSLogin(login) ? LocalePhoneNumber.formatPhoneNumber(login) : login;
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 @@ -76,9 +76,9 @@ const HeaderView = (props) => {
const isChatRoom = ReportUtils.isChatRoom(props.report);
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(props.report);
const isTaskReport = ReportUtils.isTaskReport(props.report);
const reportHeaderData = isTaskReport && !_.isEmpty(props.parentReport) && (!isThread || isTaskReport) ? props.parentReport : props.report;
const reportHeaderData = (isTaskReport || !isThread) && !_.isEmpty(props.parentReport) ? props.parentReport : props.report;
const title = ReportUtils.getReportName(reportHeaderData);
const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData);
const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData, props.parentReport);
const isConcierge = participants.length === 1 && _.contains(participants, CONST.EMAIL.CONCIERGE);
const isAutomatedExpensifyAccount = participants.length === 1 && ReportUtils.hasAutomatedExpensifyEmails(participants);
const guideCalendarLink = lodashGet(props.account, 'guideCalendarLink');
Expand Down

0 comments on commit da8c1c5

Please sign in to comment.