Skip to content

Commit 7a99206

Browse files
authored
Merge pull request #22099 from hungvu193/fix-21719
prevent user with no permission from flag comment
2 parents 3e02ef4 + 0a05097 commit 7a99206

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/libs/ReportUtils.js

+21-19
Original file line numberDiff line numberDiff line change
@@ -211,24 +211,6 @@ function canEditReportAction(reportAction) {
211211
);
212212
}
213213

214-
/**
215-
* Can only flag if:
216-
*
217-
* - It was written by someone else
218-
* - It's an ADDCOMMENT that is not an attachment
219-
*
220-
* @param {Object} reportAction
221-
* @returns {Boolean}
222-
*/
223-
function canFlagReportAction(reportAction) {
224-
return (
225-
!loginList.includes(reportAction.actorEmail) &&
226-
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT &&
227-
!ReportActionsUtils.isDeletedAction(reportAction) &&
228-
!ReportActionsUtils.isCreatedTaskReportAction(reportAction)
229-
);
230-
}
231-
232214
/**
233215
* Whether the Money Request report is settled
234216
*
@@ -2123,6 +2105,26 @@ function chatIncludesChronos(report) {
21232105
return report.participantAccountIDs && _.contains(report.participantAccountIDs, CONST.ACCOUNT_ID.CHRONOS);
21242106
}
21252107

2108+
/**
2109+
* Can only flag if:
2110+
*
2111+
* - It was written by someone else
2112+
* - It's an ADDCOMMENT that is not an attachment
2113+
*
2114+
* @param {Object} reportAction
2115+
* @param {number} reportID
2116+
* @returns {Boolean}
2117+
*/
2118+
function canFlagReportAction(reportAction, reportID) {
2119+
return (
2120+
!loginList.includes(reportAction.actorEmail) &&
2121+
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT &&
2122+
!ReportActionsUtils.isDeletedAction(reportAction) &&
2123+
!ReportActionsUtils.isCreatedTaskReportAction(reportAction) &&
2124+
isAllowedToComment(getReport(reportID))
2125+
);
2126+
}
2127+
21262128
/**
21272129
* Whether flag comment page should show
21282130
*
@@ -2133,7 +2135,7 @@ function chatIncludesChronos(report) {
21332135

21342136
function shouldShowFlagComment(reportAction, report) {
21352137
return (
2136-
canFlagReportAction(reportAction) &&
2138+
canFlagReportAction(reportAction, report.reportID) &&
21372139
!isArchivedRoom(report) &&
21382140
!chatIncludesChronos(report) &&
21392141
!isConciergeChatReport(report.reportID) &&

0 commit comments

Comments
 (0)