Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 22383 Whole thread disappears if the thread header is flagged as an Assault or Harassment #28002

Merged
merged 47 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
887d700
fix: 22383 Whole thread disappears if the thread header is flagged as…
tienifr Sep 22, 2023
dd12b4b
Merge branch 'main' into fix/22383
tienifr Sep 26, 2023
fe3ed22
fix: LHN message
tienifr Sep 26, 2023
8910bb9
fix deleted message
tienifr Sep 26, 2023
787d2e3
fix change to first
tienifr Sep 26, 2023
aa74189
fix: isThreadParent
tienifr Sep 27, 2023
0487fc8
fix lastNonWhisper
tienifr Sep 27, 2023
8495c9c
Merge branch 'main' into fix/22383
tienifr Sep 29, 2023
b823f33
Merge branch 'main' into fix/22383
tienifr Oct 2, 2023
497e154
Merge branch 'main' into fix/22383
tienifr Oct 4, 2023
4ed7229
Merge branch 'main' into fix/22383
tienifr Oct 4, 2023
24472aa
merge main
tienifr Oct 20, 2023
de6bb44
merge main
tienifr Oct 20, 2023
53bc74c
fix remove js file
tienifr Oct 20, 2023
d19c508
merge main
tienifr Oct 27, 2023
d3921d9
fix ts
tienifr Oct 27, 2023
fdf8f9f
Merge branch 'main' into fix/22383
tienifr Oct 30, 2023
b74fb09
Merge branch 'main' into fix/22383
tienifr Nov 3, 2023
34d4a7e
merge main
tienifr Nov 3, 2023
3bdd520
merge main
tienifr Nov 8, 2023
735a9d3
merge main
tienifr Nov 24, 2023
ddc84e9
merge main
tienifr Nov 29, 2023
60dc28a
Merge branch 'main' into fix/22383
tienifr Dec 1, 2023
9887a0c
lint fix
tienifr Dec 1, 2023
dcadb7a
Merge branch 'main' into fix/22383
tienifr Dec 4, 2023
567d773
merge main
tienifr Dec 11, 2023
9ec12d5
Merge branch 'main' into fix/22383
tienifr Dec 13, 2023
0f7ae76
merge main
tienifr Dec 13, 2023
3bc8074
Merge branch 'main' into fix/22383
tienifr Dec 20, 2023
72b04f0
Merge branch 'main' into fix/22383
tienifr Dec 25, 2023
676eb03
merge main
tienifr Dec 25, 2023
eb12d80
lint fix
tienifr Dec 25, 2023
86edad8
Merge branch 'main' into fix/22383
tienifr Jan 4, 2024
f3cf917
Merge branch 'main' into fix/22383
tienifr Jan 5, 2024
b0aaf2b
resolve conflict
tienifr Jan 5, 2024
f791be9
Merge branch 'main' into fix/22383
tienifr Jan 8, 2024
97f06e4
fix lodash import
tienifr Jan 8, 2024
8c0585e
Merge branch 'main' into fix/22383
tienifr Jan 17, 2024
a34424f
clean code
tienifr Jan 17, 2024
d95d5d2
add comment
tienifr Jan 24, 2024
abf28d4
revert isThreadParentMessage
tienifr Jan 25, 2024
21855f7
lint fix
tienifr Jan 25, 2024
d15d989
fix conflict
tienifr Jan 29, 2024
19839c2
update report action fragment
tienifr Jan 29, 2024
14abf75
remove js file
tienifr Jan 29, 2024
d6fed2b
lint fix
tienifr Jan 29, 2024
3ebb157
fix conflict
tienifr Jan 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -368,7 +368,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 @@ -2335,7 +2335,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 @@ -3526,17 +3527,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 @@ -595,7 +597,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 @@ -286,5 +286,6 @@ export type {
OriginalMessageAddComment,
OriginalMessageSource,
OriginalMessageReimbursementDequeued,
DecisionName,
PaymentMethodType,
};
Loading