From c6f599adc86585b505a355b00916d0826876f0c5 Mon Sep 17 00:00:00 2001 From: Vit Horacek <36083550+mountiny@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:00:02 +0200 Subject: [PATCH] Revert "Fix unread issue in combine report" --- .../LHNOptionsList/LHNOptionsList.tsx | 3 --- .../LHNOptionsList/OptionRowLHN.tsx | 5 ---- .../LHNOptionsList/OptionRowLHNData.tsx | 3 --- src/components/LHNOptionsList/types.ts | 3 --- src/libs/ReportUtils.ts | 1 - src/libs/SidebarUtils.ts | 5 +--- .../BaseReportActionContextMenu.tsx | 5 ---- .../report/ContextMenu/ContextMenuActions.tsx | 6 +---- .../PopoverReportActionContextMenu.tsx | 4 --- .../ContextMenu/ReportActionContextMenu.ts | 3 --- src/pages/home/report/ReportActionItem.tsx | 1 - src/pages/home/report/ReportActionsList.tsx | 26 +++---------------- tests/perf-test/SidebarUtils.perf-test.ts | 1 - 13 files changed, 5 insertions(+), 61 deletions(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 469f17258a7f..8c43ae542932 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -116,8 +116,6 @@ function LHNOptionsList({ const hasDraftComment = DraftCommentUtils.isValidDraftComment(draftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`]); const sortedReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(itemReportActions); const lastReportAction = sortedReportActions[0]; - const transactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(reportID, itemReportActions); - const transactionThreadReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null; // Get the transaction for the last report action let lastReportActionTransactionID = ''; @@ -131,7 +129,6 @@ function LHNOptionsList({ {}, opti false, optionItem.isPinned, !!optionItem.isUnread, - [], - false, - () => {}, - false, - optionItem.transactionThreadReportID, ); }; diff --git a/src/components/LHNOptionsList/OptionRowLHNData.tsx b/src/components/LHNOptionsList/OptionRowLHNData.tsx index 1d6cc636f939..c80017c39a3d 100644 --- a/src/components/LHNOptionsList/OptionRowLHNData.tsx +++ b/src/components/LHNOptionsList/OptionRowLHNData.tsx @@ -27,7 +27,6 @@ function OptionRowLHNData({ lastReportActionTransaction = {}, transactionViolations, canUseViolations, - transactionThreadReport, ...propsToForward }: OptionRowLHNDataProps) { const reportID = propsToForward.reportID; @@ -48,7 +47,6 @@ function OptionRowLHNData({ policy, parentReportAction, hasViolations: !!shouldDisplayViolations, - transactionThreadReport, }); if (deepEqual(item, optionItemRef.current)) { return optionItemRef.current; @@ -72,7 +70,6 @@ function OptionRowLHNData({ transactionViolations, canUseViolations, receiptTransactions, - transactionThreadReport, ]); return ( diff --git a/src/components/LHNOptionsList/types.ts b/src/components/LHNOptionsList/types.ts index 79b5f5ad3889..0f0c921747b4 100644 --- a/src/components/LHNOptionsList/types.ts +++ b/src/components/LHNOptionsList/types.ts @@ -74,9 +74,6 @@ type OptionRowLHNDataProps = { /** The full data of the report */ fullReport: OnyxEntry; - /** The transaction thread report associated with the current report – applicable only for one-transaction money reports */ - transactionThreadReport: OnyxEntry; - /** The policy which the user has access to and which the report could be tied to */ policy?: OnyxEntry; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ca5080cc4afc..e406b750bfd3 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -441,7 +441,6 @@ type OptionData = { reportID?: string; enabled?: boolean; data?: Partial; - transactionThreadReportID?: string | null; } & Report; type OnyxDataTaskAssigneeChat = { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 248878df2bf8..4f1a35ee1d87 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -190,7 +190,6 @@ function getOptionData({ policy, parentReportAction, hasViolations, - transactionThreadReport, }: { report: OnyxEntry; reportActions: OnyxEntry; @@ -199,7 +198,6 @@ function getOptionData({ policy: OnyxEntry | undefined; parentReportAction: OnyxEntry | undefined; hasViolations: boolean; - transactionThreadReport: OnyxEntry; }): ReportUtils.OptionData | undefined { // When a user signs out, Onyx is cleared. Due to the lazy rendering with a virtual list, it's possible for // this method to be called after the Onyx data has been cleared out. In that case, it's fine to do @@ -236,7 +234,6 @@ function getOptionData({ isWaitingOnBankAccount: false, isAllowedToComment: true, isDeletedParentAction: false, - transactionThreadReportID: transactionThreadReport?.reportID, }; let participantAccountIDs = report.participantAccountIDs ?? []; @@ -269,7 +266,7 @@ function getOptionData({ result.statusNum = report.statusNum; // When the only message of a report is deleted lastVisibileActionCreated is not reset leading to wrongly // setting it Unread so we add additional condition here to avoid empty chat LHN from being bold. - result.isUnread = (ReportUtils.isUnread(report) && !!report.lastActorAccountID) || (ReportUtils.isUnread(transactionThreadReport) && !!transactionThreadReport?.lastActorAccountID); + result.isUnread = ReportUtils.isUnread(report) && !!report.lastActorAccountID; result.isUnreadWithMention = ReportUtils.isUnreadWithMention(report); result.isPinned = report.isPinned; result.iouReportID = report.iouReportID; diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index 8e2c9d6f09b3..46ebdd751762 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -49,9 +49,6 @@ type BaseReportActionContextMenuProps = BaseReportActionContextMenuOnyxProps & { // eslint-disable-next-line react/no-unused-prop-types originalReportID: string; - /** The ID of transaction thread report associated with the current report, if any */ - transactionThreadReportID: string; - /** * If true, this component will be a small, row-oriented menu that displays icons but not text. * If false, this component will be a larger, column-oriented menu that displays icons alongside text in each row. @@ -120,7 +117,6 @@ function BaseReportActionContextMenu({ checkIfContextMenuActive, disabledActions = [], setIsEmojiPickerActive, - transactionThreadReportID, }: BaseReportActionContextMenuProps) { const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); @@ -249,7 +245,6 @@ function BaseReportActionContextMenu({ interceptAnonymousUser, openOverflowMenu, setIsEmojiPickerActive, - transactionThreadReportID, }; if ('renderContent' in contextAction) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index a09f0355b996..438d09e778b4 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -79,7 +79,6 @@ type ContextMenuActionPayload = { event?: GestureResponderEvent | MouseEvent | KeyboardEvent; setIsEmojiPickerActive?: (state: boolean) => void; anchorRef?: MutableRefObject; - transactionThreadReportID?: string; }; type OnPress = (closePopover: boolean, payload: ContextMenuActionPayload, selection?: string, reportID?: string, draftMessage?: string) => void; @@ -214,11 +213,8 @@ const ContextMenuActions: ContextMenuAction[] = [ successIcon: Expensicons.Checkmark, shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, reportID, isPinnedChat, isUnreadChat) => type === CONST.CONTEXT_MENU_TYPES.REPORT && isUnreadChat, - onPress: (closePopover, {reportID, transactionThreadReportID}) => { + onPress: (closePopover, {reportID}) => { Report.readNewestAction(reportID); - if (transactionThreadReportID && transactionThreadReportID !== '0') { - Report.readNewestAction(transactionThreadReportID); - } if (closePopover) { hideContextMenu(true, ReportActionComposeFocusManager.focus); } diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx index 38fd37ee4d26..6cb688ff2558 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx @@ -37,7 +37,6 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef>(null); const reportActionIDRef = useRef('0'); const originalReportIDRef = useRef('0'); - const transactionThreadReportIDRef = useRef('0'); const selectionRef = useRef(''); const reportActionDraftMessageRef = useRef(); @@ -172,7 +171,6 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef {}, isOverflowMenu = false, - transactionThreadReportID = undefined, ) => { const {pageX = 0, pageY = 0} = extractPointerEvent(event); contextMenuAnchorRef.current = contextMenuAnchor; @@ -214,7 +212,6 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef void, isOverflowMenu?: boolean, - transactionThreadReportID?: string, ) => void; type ReportActionContextMenu = { @@ -120,7 +119,6 @@ function showContextMenu( shouldCloseOnTarget = false, setIsEmojiPickerActive = () => {}, isOverflowMenu = false, - transactionThreadReportID = '0', ) { if (!contextMenuRef.current) { return; @@ -151,7 +149,6 @@ function showContextMenu( shouldCloseOnTarget, setIsEmojiPickerActive, isOverflowMenu, - transactionThreadReportID, ); } diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index ecdffc9ac627..c07b693001e0 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -919,7 +919,6 @@ function ReportActionItem({ isChronosReport={ReportUtils.chatIncludesChronos(originalReport)} checkIfContextMenuActive={toggleContextMenuFromActiveReportAction} setIsEmojiPickerActive={setIsEmojiPickerActive} - transactionThreadReportID={transactionThreadReport?.reportID ?? '0'} /> { - resetUnreadMarker(newLastReadTime); - setMessageManuallyMarkedUnread(new Date().getTime()); - }); - - readNewestActionSubscriptionForTransactionThread = DeviceEventEmitter.addListener(`readNewestAction_${transactionThreadReport?.reportID}`, (newLastReadTime) => { - resetUnreadMarker(newLastReadTime); - setMessageManuallyMarkedUnread(0); - }); - } - return () => { unreadActionSubscription.remove(); readNewestActionSubscription.remove(); deletedReportActionSubscription.remove(); - unreadActionSubscriptionForTransactionThread?.remove(); - readNewestActionSubscriptionForTransactionThread?.remove(); }; - }, [report.reportID, transactionThreadReport?.reportID]); + }, [report.reportID]); useEffect(() => { if (linkedReportActionID) { @@ -416,9 +399,6 @@ function ReportActionsList({ reportScrollManager.scrollToBottom(); readActionSkipped.current = false; Report.readNewestAction(report.reportID); - if (transactionThreadReport?.reportID) { - Report.readNewestAction(transactionThreadReport?.reportID); - } }; /** diff --git a/tests/perf-test/SidebarUtils.perf-test.ts b/tests/perf-test/SidebarUtils.perf-test.ts index 75503e5179a4..cceb3ae437b9 100644 --- a/tests/perf-test/SidebarUtils.perf-test.ts +++ b/tests/perf-test/SidebarUtils.perf-test.ts @@ -107,7 +107,6 @@ describe('SidebarUtils', () => { policy, parentReportAction, hasViolations: false, - transactionThreadReport: null, }), ); });