Skip to content

Commit

Permalink
Merge pull request #24091 from dukenv0307/fix/22691-regression
Browse files Browse the repository at this point in the history
[CP Staging] Fix user cannot open detail page of chat room

(cherry picked from commit a67e8af)
  • Loading branch information
Beamanator authored and OSBotify committed Aug 4, 2023
1 parent 5ac39a1 commit 7a7b1c1
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,6 @@ function isOptimisticPersonalDetail(accountID) {
return _.isEmpty(allPersonalDetails[accountID]) || !!allPersonalDetails[accountID].isOptimisticPersonalDetail;
}

/**
* Check if report is a DM and personal detail of participant is optimistic data
* @param {String} report
* @returns {Boolean}
*/
function shouldDisableDetailPage(report) {
const participants = lodashGet(report, 'participantAccountIDs', []);
const isMultipleParticipant = participants.length > 1;
return !isMultipleParticipant && isOptimisticPersonalDetail(participants[0]) && !report.parentReportID;
}

/**
* Checks if a report is a task report from a policy expense chat.
*
Expand Down Expand Up @@ -461,6 +450,38 @@ function isConciergeChatReport(report) {
}

/**
<<<<<<< HEAD
=======
* Check if the report is a single chat report that isn't a thread
* and personal detail of participant is optimistic data
* @param {Object} report
* @param {Array} report.participantAccountIDs
* @returns {Boolean}
*/
function shouldDisableDetailPage(report) {
const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []);

if (isChatRoom(report) || isPolicyExpenseChat(report) || isChatThread(report)) {
return false;
}
if (participantAccountIDs.length === 1) {
return isOptimisticPersonalDetail(participantAccountIDs[0]);
}
return false;
}

/**
* Returns true if this report has only one participant and it's an Expensify account.
* @param {Object} report
* @returns {Boolean}
*/
function isExpensifyOnlyParticipantInReport(report) {
const reportParticipants = _.without(lodashGet(report, 'participantAccountIDs', []), currentUserAccountID);
return lodashGet(report, 'participantAccountIDs', []).length === 1 && _.some(reportParticipants, (accountID) => _.contains(CONST.EXPENSIFY_ACCOUNT_IDS, accountID));
}

/**
>>>>>>> a67e8af (Merge pull request #24091 from dukenv0307/fix/22691-regression)
* Returns true if there are any Expensify accounts (i.e. with domain 'expensify.com') in the set of accountIDs
* by cross-referencing the accountIDs with personalDetails.
*
Expand Down

0 comments on commit 7a7b1c1

Please sign in to comment.