Skip to content

Commit

Permalink
set text and alternate text
Browse files Browse the repository at this point in the history
  • Loading branch information
akamefi202 committed Oct 12, 2023
1 parent 1b84d3c commit fdca0ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
15 changes: 5 additions & 10 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,9 @@ function getLastMessageTextForReport(report) {
* @param {Object} options
* @param {Boolean} [options.showChatPreviewLine]
* @param {Boolean} [options.forcePolicyNamePreview]
* @param {Boolean} [options.checkPolicyOwner]
* @returns {Object}
*/
function createOption(accountIDs, personalDetails, report, reportActions = {}, {showChatPreviewLine = false, forcePolicyNamePreview = false, checkPolicyOwner = true}) {
function createOption(accountIDs, personalDetails, report, reportActions = {}, {showChatPreviewLine = false, forcePolicyNamePreview = false}) {
const result = {
text: null,
alternateText: null,
Expand Down Expand Up @@ -486,7 +485,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
result.policyID = report.policyID;

hasMultipleParticipants = personalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat;
subtitle = ReportUtils.getChatRoomSubtitle(report, checkPolicyOwner);
subtitle = ReportUtils.getChatRoomSubtitle(report);

const lastMessageTextFromReport = getLastMessageTextForReport(report);
const lastActorDetails = personalDetailMap[report.lastActorAccountID] || null;
Expand All @@ -512,12 +511,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
} else {
result.alternateText = showChatPreviewLine && lastMessageText ? lastMessageText : LocalePhoneNumber.formatPhoneNumber(personalDetail.login);
}

if (result.isPolicyExpenseChat && !checkPolicyOwner) {
reportName = ReportUtils.getPolicyName(report);
} else {
reportName = ReportUtils.getReportName(report);
}
reportName = ReportUtils.getReportName(report);
} else {
reportName = ReportUtils.getDisplayNameForParticipant(accountIDs[0]);
result.keyForList = String(accountIDs[0]);
Expand Down Expand Up @@ -557,9 +551,10 @@ function getPolicyExpenseReportOption(report) {
{
showChatPreviewLine: false,
forcePolicyNamePreview: false,
checkPolicyOwner: false,
},
);
option.text = ReportUtils.getPolicyName(report);
option.alternateText = Localize.translateLocal('workspace.common.workspace');
option.selected = report.selected;
return option;
}
Expand Down
5 changes: 2 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1859,10 +1859,9 @@ function getRootReportAndWorkspaceName(report) {
/**
* Get either the policyName or domainName the chat is tied to
* @param {Object} report
* @param {Boolean} checkPolicyOwner
* @returns {String}
*/
function getChatRoomSubtitle(report, checkPolicyOwner = true) {
function getChatRoomSubtitle(report) {
if (isChatThread(report)) {
return '';
}
Expand All @@ -1873,7 +1872,7 @@ function getChatRoomSubtitle(report, checkPolicyOwner = true) {
// The domainAll rooms are just #domainName, so we ignore the prefix '#' to get the domainName
return report.reportName.substring(1);
}
if ((isPolicyExpenseChat(report) && (!checkPolicyOwner || report.isOwnPolicyExpenseChat)) || isExpenseReport(report)) {
if ((isPolicyExpenseChat(report) && report.isOwnPolicyExpenseChat) || isExpenseReport(report)) {
return Localize.translateLocal('workspace.common.workspace');
}
if (isArchivedRoom(report)) {
Expand Down

0 comments on commit fdca0ec

Please sign in to comment.