Skip to content

Commit

Permalink
Merge pull request #28002 from tienifr/fix/22383
Browse files Browse the repository at this point in the history
fix: 22383 Whole thread disappears if the thread header is flagged as an Assault or Harassment
  • Loading branch information
dangrous authored Feb 2, 2024
2 parents e6fee5f + 3ebb157 commit 8fa0994
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
lastMessageTextFromReport = ReportUtils.getReimbursementDeQueuedActionMessage(report);
} else if (ReportActionUtils.isDeletedParentAction(lastReportAction) && ReportUtils.isChatReport(report)) {
lastMessageTextFromReport = ReportUtils.getDeletedParentActionMessageForChatReport(lastReportAction);
} else if (ReportActionUtils.isPendingRemove(lastReportAction) && ReportActionUtils.isThreadParentMessage(lastReportAction, report?.reportID ?? '')) {
lastMessageTextFromReport = Localize.translateLocal('parentReportAction.hiddenMessage');
} else if (ReportUtils.isReportMessageAttachment({text: report?.lastMessageText ?? '', html: report?.lastMessageHtml, translationKey: report?.lastMessageTranslationKey, type: ''})) {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
lastMessageTextFromReport = `[${Localize.translateLocal((report?.lastMessageTranslationKey || 'common.attachment') as TranslationPaths)}]`;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key:
return false;
}

if (isPendingRemove(reportAction)) {
if (isPendingRemove(reportAction) && !reportAction.childVisibleActionCount) {
return false;
}

Expand Down
8 changes: 3 additions & 5 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2425,7 +2425,8 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
}
if (
parentReportAction?.message?.[0]?.moderationDecision?.decision === CONST.MODERATION.MODERATOR_DECISION_PENDING_HIDE ||
parentReportAction?.message?.[0]?.moderationDecision?.decision === CONST.MODERATION.MODERATOR_DECISION_HIDDEN
parentReportAction?.message?.[0]?.moderationDecision?.decision === CONST.MODERATION.MODERATOR_DECISION_HIDDEN ||
parentReportAction?.message?.[0]?.moderationDecision?.decision === CONST.MODERATION.MODERATOR_DECISION_PENDING_REMOVE
) {
return Localize.translateLocal('parentReportAction.hiddenMessage');
}
Expand Down Expand Up @@ -3616,17 +3617,14 @@ function canSeeDefaultRoom(report: OnyxEntry<Report>, policies: OnyxCollection<P
}

function canAccessReport(report: OnyxEntry<Report>, policies: OnyxCollection<Policy>, betas: OnyxEntry<Beta[]>): boolean {
if (isThread(report) && ReportActionsUtils.isPendingRemove(ReportActionsUtils.getParentReportAction(report))) {
return false;
}

// We hide default rooms (it's basically just domain rooms now) from people who aren't on the defaultRooms beta.
if (isDefaultRoom(report) && !canSeeDefaultRoom(report, policies, betas)) {
return false;
}

return true;
}

/**
* Check if the report is the parent report of the currently viewed report or at least one child report has report action
*/
Expand Down
13 changes: 9 additions & 4 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ function ReportActionItem(props) {
}

setModerationDecision(latestDecision);
if (!_.contains([CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING], latestDecision)) {
if (!_.contains([CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING], latestDecision) && !ReportActionsUtils.isPendingRemove(props.action)) {
setIsHidden(true);
return;
}
setIsHidden(false);
}, [latestDecision, props.action.actionName]);
}, [latestDecision, props.action]);

const toggleContextMenuFromActiveReportAction = useCallback(() => {
setIsContextMenuActive(ReportActionContextMenu.isActiveReportAction(props.action.reportActionID));
Expand Down Expand Up @@ -452,7 +452,9 @@ function ReportActionItem(props) {
} else if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.MARKEDREIMBURSED) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getMarkedReimbursedMessage(props.action)} />;
} else {
const hasBeenFlagged = !_.contains([CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING], moderationDecision);
const hasBeenFlagged =
!_.contains([CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING], moderationDecision) &&
!ReportActionsUtils.isPendingRemove(props.action);
children = (
<ShowContextMenuContext.Provider value={contextValue}>
{_.isUndefined(props.draftMessage) ? (
Expand Down Expand Up @@ -594,7 +596,10 @@ function ReportActionItem(props) {
report={props.report}
iouReport={props.iouReport}
isHovered={hovered}
hasBeenFlagged={!_.contains([CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING], moderationDecision)}
hasBeenFlagged={
!_.contains([CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING], moderationDecision) &&
!ReportActionsUtils.isPendingRemove(props.action)
}
>
{content}
</ReportActionItemSingle>
Expand Down
9 changes: 8 additions & 1 deletion src/pages/home/report/ReportActionItemFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import convertToLTR from '@libs/convertToLTR';
import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import type * as OnyxCommon from '@src/types/onyx/OnyxCommon';
import type {OriginalMessageSource} from '@src/types/onyx/OriginalMessage';
import type {DecisionName, OriginalMessageSource} from '@src/types/onyx/OriginalMessage';
import type {Message} from '@src/types/onyx/ReportAction';
import AttachmentCommentFragment from './comment/AttachmentCommentFragment';
import TextCommentFragment from './comment/TextCommentFragment';
Expand Down Expand Up @@ -55,6 +55,8 @@ type ReportActionItemFragmentProps = {

/** The pending action for the report action */
pendingAction?: OnyxCommon.PendingAction;

moderationDecision?: DecisionName;
};

function ReportActionItemFragment({
Expand All @@ -71,6 +73,7 @@ function ReportActionItemFragment({
isApprovedOrSubmittedReportAction = false,
isFragmentContainingDisplayName = false,
displayAsGroup = false,
moderationDecision,
}: ReportActionItemFragmentProps) {
const styles = useThemeStyles();
const {isOffline} = useNetwork();
Expand All @@ -88,6 +91,10 @@ function ReportActionItemFragment({
return <RenderHTML html={`<comment>${translate('parentReportAction.deletedMessage')}</comment>`} />;
}

if (isThreadParentMessage && moderationDecision === CONST.MODERATION.MODERATOR_DECISION_PENDING_REMOVE) {
return <RenderHTML html={`<comment>${translate('parentReportAction.hiddenMessage')}</comment>`} />;
}

if (ReportUtils.isReportMessageAttachment(fragment)) {
return (
<AttachmentCommentFragment
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionItemMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHid
// to decide if the fragment should be from left to right for RTL display names e.g. Arabic for proper
// formatting.
isFragmentContainingDisplayName={index === 0}
moderationDecision={action.message?.[0].moderationDecision?.decision}
/>
));

Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionItemSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ function ReportActionItemSingle({
delegateAccountID={action.delegateAccountID}
isSingleLine
actorIcon={icon}
moderationDecision={action.message?.[0].moderationDecision?.decision}
/>
))}
</PressableWithoutFeedback>
Expand Down
1 change: 1 addition & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,6 @@ export type {
OriginalMessageChronosOOOList,
OriginalMessageSource,
OriginalMessageReimbursementDequeued,
DecisionName,
PaymentMethodType,
};

0 comments on commit 8fa0994

Please sign in to comment.