Skip to content

Commit

Permalink
Merge pull request #29994 from Expensify/youssef_disallow_flagging_wh…
Browse files Browse the repository at this point in the history
…ispers

Disallow flagging whispers
  • Loading branch information
danieldoglas authored Oct 23, 2023
2 parents e73cd31 + 704af3e commit e2d4845
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3289,20 +3289,34 @@ function chatIncludesChronos(report) {
/**
* Can only flag if:
*
* - It was written by someone else
* - It was written by someone else and isn't a whisper
* - It's a welcome message whisper
* - It's an ADDCOMMENT that is not an attachment
*
* @param {Object} reportAction
* @param {number} reportID
* @returns {Boolean}
*/
function canFlagReportAction(reportAction, reportID) {
const report = getReport(reportID);
const isCurrentUserAction = reportAction.actorAccountID === currentUserAccountID;

if (ReportActionsUtils.isWhisperAction(reportAction)) {
// Allow flagging welcome message whispers as they can be set by any room creator
if (report.welcomeMessage && !isCurrentUserAction && lodashGet(reportAction, 'originalMessage.html') === report.welcomeMessage) {
return true;
}

// Disallow flagging the rest of whisper as they are sent by us
return false;
}

return (
reportAction.actorAccountID !== currentUserAccountID &&
!isCurrentUserAction &&
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT &&
!ReportActionsUtils.isDeletedAction(reportAction) &&
!ReportActionsUtils.isCreatedTaskReportAction(reportAction) &&
isAllowedToComment(getReport(reportID))
isAllowedToComment(report)
);
}

Expand Down

0 comments on commit e2d4845

Please sign in to comment.