Skip to content

Commit

Permalink
Merge pull request #21836 from s-alves10/fix/issue-20810
Browse files Browse the repository at this point in the history
Fix/issue 20810
  • Loading branch information
tylerkaraszewski authored Jun 30, 2023
2 parents 2f6002f + bba5e3d commit 6b4bddf
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,18 @@ function ReportActionItem(props) {

// Hide the message if it is being moderated for a higher offense, or is hidden by a moderator
// Removed messages should not be shown anyway and should not need this flow

const decisions = lodashGet(props, ['action', 'message', 0, 'moderationDecisions'], []);
const latestDecision = lodashGet(_.last(decisions), 'decision', '');
useEffect(() => {
if (!props.action.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT || _.isEmpty(props.action.message[0].moderationDecisions)) {
if (!props.action.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT || _.isEmpty(latestDecision)) {
return;
}

// Right now we are only sending the latest moderationDecision to the frontend even though it is an array
let decisions = props.action.message[0].moderationDecisions;
if (decisions.length > 1) {
decisions = decisions.slice(-1);
}
const latestDecision = decisions[0];
if (latestDecision.decision === CONST.MODERATION.MODERATOR_DECISION_PENDING_HIDE || latestDecision.decision === CONST.MODERATION.MODERATOR_DECISION_HIDDEN) {
if (latestDecision === CONST.MODERATION.MODERATOR_DECISION_PENDING_HIDE || latestDecision === CONST.MODERATION.MODERATOR_DECISION_HIDDEN) {
setIsHidden(true);
}
setModerationDecision(latestDecision.decision);

// props.action.message doesn't need to be a dependency, we only need to check the change of props.action.message[0].moderationDecisions
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [props.action.message[0].moderationDecisions, props.action.actionName]);
setModerationDecision(latestDecision);
}, [latestDecision, props.action.actionName]);

const toggleContextMenuFromActiveReportAction = useCallback(() => {
setIsContextMenuActive(ReportActionContextMenu.isActiveReportAction(props.action.reportActionID));
Expand Down

0 comments on commit 6b4bddf

Please sign in to comment.