diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 4ddbf032867c..e0ad572baa1c 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -211,24 +211,6 @@ function canEditReportAction(reportAction) { ); } -/** - * Can only flag if: - * - * - It was written by someone else - * - It's an ADDCOMMENT that is not an attachment - * - * @param {Object} reportAction - * @returns {Boolean} - */ -function canFlagReportAction(reportAction) { - return ( - !loginList.includes(reportAction.actorEmail) && - reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && - !ReportActionsUtils.isDeletedAction(reportAction) && - !ReportActionsUtils.isCreatedTaskReportAction(reportAction) - ); -} - /** * Whether the Money Request report is settled * @@ -2088,6 +2070,26 @@ function chatIncludesChronos(report) { return report.participantAccountIDs && _.contains(report.participantAccountIDs, CONST.ACCOUNT_ID.CHRONOS); } +/** + * Can only flag if: + * + * - It was written by someone else + * - It's an ADDCOMMENT that is not an attachment + * + * @param {Object} reportAction + * @param {number} reportID + * @returns {Boolean} + */ +function canFlagReportAction(reportAction, reportID) { + return ( + !loginList.includes(reportAction.actorEmail) && + reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && + !ReportActionsUtils.isDeletedAction(reportAction) && + !ReportActionsUtils.isCreatedTaskReportAction(reportAction) && + isAllowedToComment(getReport(reportID)) + ); +} + /** * Whether flag comment page should show * @@ -2098,7 +2100,7 @@ function chatIncludesChronos(report) { function shouldShowFlagComment(reportAction, report) { return ( - canFlagReportAction(reportAction) && + canFlagReportAction(reportAction, report.reportID) && !isArchivedRoom(report) && !chatIncludesChronos(report) && !isConciergeChatReport(report.reportID) &&