Skip to content

Fix - Display @Hidden mentions in LHN #59551

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

Merged
merged 10 commits into from
May 1, 2025
15 changes: 14 additions & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@ import Navigation from './Navigation/Navigation';
import Parser from './Parser';
import Performance from './Performance';
import Permissions from './Permissions';
import {getDisplayNameOrDefault} from './PersonalDetailsUtils';
import {getDisplayNameOrDefault, getPersonalDetailsByIDs} from './PersonalDetailsUtils';
import {addSMSDomainIfPhoneNumber, parsePhoneNumber} from './PhoneNumber';
import {canSendInvoiceFromWorkspace, getSubmitToAccountID, isUserInvitedToWorkspace} from './PolicyUtils';
import {
getCombinedReportActions,
getExportIntegrationLastMessageText,
getIOUReportIDFromReportActionPreview,
getLeaveRoomMessage,
getMentionedAccountIDsFromAction,
getMessageOfOldDotReportAction,
getOneTransactionThreadReportID,
getOriginalMessage,
getReportActionHtml,
getReportActionMessageText,
getSortedReportActions,
getUpdateRoomDescriptionMessage,
Expand Down Expand Up @@ -682,6 +684,10 @@ function getIOUReportIDOfLastAction(report: OnyxEntry<Report>): string | undefin
return getReportOrDraftReport(getIOUReportIDFromReportActionPreview(lastAction))?.reportID;
}

function hasHiddenDisplayNames(accountIDs: number[]) {
return getPersonalDetailsByIDs({accountIDs, currentUserAccountID: 0}).some((personalDetail) => getDisplayNameOrDefault(personalDetail) === translateLocal('common.hidden'));
}

/**
* Get the last message text from the report directly or from other sources for special cases.
*/
Expand Down Expand Up @@ -807,6 +813,13 @@ function getLastMessageTextForReport(
if (reportID && !isArchivedReport(reportNameValuePairs) && report.lastActionType === CONST.REPORT.ACTIONS.TYPE.CLOSED) {
return lastMessageTextFromReport || (getReportLastMessage(reportID).lastMessageText ?? '');
}

// When the last report action has unkown mentions (@Hidden), we want to consistently show @Hidden in LHN and report screen
// so we reconstruct the last message text of the report from the last report action.
if (!lastMessageTextFromReport && lastReportAction && hasHiddenDisplayNames(getMentionedAccountIDsFromAction(lastReportAction))) {
lastMessageTextFromReport = Parser.htmlToText(getReportActionHtml(lastReportAction));
}

return lastMessageTextFromReport || (report?.lastMessageText ?? '');
}

Expand Down
1 change: 1 addition & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,7 @@ export {
isReportActionDeprecated,
isReportPreviewAction,
isReversedTransaction,
getMentionedAccountIDsFromAction,
isRoomChangeLogAction,
isSentMoneyReportAction,
isSplitBillAction,
Expand Down