From 20ddda989d726f338fe1d898812b4a42508bacda Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 29 Nov 2023 12:38:09 +0100 Subject: [PATCH 1/6] do not display new line when creating request money --- src/pages/home/report/ReportActionsList.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index e1230d7219dbf..6ad79f9f488a2 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -335,6 +335,12 @@ function ReportActionsList({ (reportAction, index) => { let shouldDisplay = false; if (!currentUnreadMarker) { + // Check if the report type is "REPORTREVIEW" and last actor is the current user. + // Return shouldDisplay new marker action (terminate flow). + // This is to avoid displaying the new line marker when a current userrequests money. + if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && reportAction.childLastActorAccountID === Report.getCurrentUserAccountID()) { + return shouldDisplay; + } const nextMessage = sortedReportActions[index + 1]; const isCurrentMessageUnread = isMessageUnread(reportAction, lastReadTimeRef.current); shouldDisplay = isCurrentMessageUnread && (!nextMessage || !isMessageUnread(nextMessage, lastReadTimeRef.current)); From 6bac4f8e367029756507220784bdde6f95e6bc9f Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 29 Nov 2023 14:21:44 +0100 Subject: [PATCH 2/6] use isReportPreviewAction --- src/pages/home/report/ReportActionsList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index 6ad79f9f488a2..6da3c1d34eb7f 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -338,7 +338,7 @@ function ReportActionsList({ // Check if the report type is "REPORTREVIEW" and last actor is the current user. // Return shouldDisplay new marker action (terminate flow). // This is to avoid displaying the new line marker when a current userrequests money. - if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW && reportAction.childLastActorAccountID === Report.getCurrentUserAccountID()) { + if (ReportActionsUtils.isReportPreviewAction(reportAction) && reportAction.childLastActorAccountID === Report.getCurrentUserAccountID()) { return shouldDisplay; } const nextMessage = sortedReportActions[index + 1]; From 8d308c5e3b8211128b1bb8fff5ca3c595b784b8b Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 30 Nov 2023 06:39:42 +0100 Subject: [PATCH 3/6] fix review comment --- src/pages/home/report/ReportActionsList.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index 6da3c1d34eb7f..716a8ab695c22 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -335,17 +335,15 @@ function ReportActionsList({ (reportAction, index) => { let shouldDisplay = false; if (!currentUnreadMarker) { - // Check if the report type is "REPORTREVIEW" and last actor is the current user. - // Return shouldDisplay new marker action (terminate flow). - // This is to avoid displaying the new line marker when a current userrequests money. - if (ReportActionsUtils.isReportPreviewAction(reportAction) && reportAction.childLastActorAccountID === Report.getCurrentUserAccountID()) { - return shouldDisplay; - } const nextMessage = sortedReportActions[index + 1]; const isCurrentMessageUnread = isMessageUnread(reportAction, lastReadTimeRef.current); shouldDisplay = isCurrentMessageUnread && (!nextMessage || !isMessageUnread(nextMessage, lastReadTimeRef.current)); if (!messageManuallyMarkedUnread) { - shouldDisplay = shouldDisplay && reportAction.actorAccountID !== Report.getCurrentUserAccountID(); + // Check if the report type is "REPORTREVIEW" and last actor is the current user. + // This is to avoid displaying the new line marker when a current userrequests money. + shouldDisplay = + shouldDisplay && + (ReportActionsUtils.isReportPreviewAction(reportAction) ? reportAction.childLastActorAccountID : reportAction.actorAccountID) !== Report.getCurrentUserAccountID(); } if (shouldDisplay) { cacheUnreadMarkers.set(report.reportID, reportAction.reportActionID); From 7f23712f67187d54f915f848a7ea70e9cc4bc547 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 1 Dec 2023 10:14:43 +0100 Subject: [PATCH 4/6] fix lint --- src/pages/home/report/ReportActionsList.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index a3d28d09da5a6..99e29d3edd5e2 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -342,9 +342,10 @@ function ReportActionsList({ const isWithinVisibleThreshold = scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD ? reportAction.created < userActiveSince.current : true; // Check if the report type is "REPORTREVIEW" and last actor is the current user. // This is to avoid displaying the new line marker when a current userrequests money. - shouldDisplay = shouldDisplay && ReportActionsUtils.isReportPreviewAction(reportAction) - ? reportAction.childLastActorAccountID - : reportAction.actorAccountID !== Report.getCurrentUserAccountID() && isWithinVisibleThreshold; + shouldDisplay = + shouldDisplay && ReportActionsUtils.isReportPreviewAction(reportAction) + ? reportAction.childLastActorAccountID + : reportAction.actorAccountID !== Report.getCurrentUserAccountID() && isWithinVisibleThreshold; } if (shouldDisplay) { cacheUnreadMarkers.set(report.reportID, reportAction.reportActionID); From 01b27d9180977283a8c874b591e6788283fad603 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 1 Dec 2023 14:28:33 +0100 Subject: [PATCH 5/6] fix failing test --- src/pages/home/report/ReportActionsList.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index d1050f4c0930a..8e63f508f8ce9 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -337,14 +337,13 @@ function ReportActionsList({ const nextMessage = sortedReportActions[index + 1]; const isCurrentMessageUnread = isMessageUnread(reportAction, lastReadTimeRef.current); shouldDisplay = isCurrentMessageUnread && (!nextMessage || !isMessageUnread(nextMessage, lastReadTimeRef.current)); - if (!messageManuallyMarkedUnread) { + if (shouldDisplay && !messageManuallyMarkedUnread) { const isWithinVisibleThreshold = scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD ? reportAction.created < userActiveSince.current : true; // Check if the report type is "REPORTREVIEW" and last actor is the current user. // This is to avoid displaying the new line marker when a current userrequests money. shouldDisplay = - shouldDisplay && ReportActionsUtils.isReportPreviewAction(reportAction) - ? reportAction.childLastActorAccountID - : reportAction.actorAccountID !== Report.getCurrentUserAccountID() && isWithinVisibleThreshold; + (ReportActionsUtils.isReportPreviewAction(reportAction) ? !reportAction.childLastActorAccountID : reportAction.actorAccountID !== Report.getCurrentUserAccountID()) && + isWithinVisibleThreshold; } if (shouldDisplay) { cacheUnreadMarkers.set(report.reportID, reportAction.reportActionID); From d82f0c8f1375e6fcc5ef32e7f2f86229159adf30 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Mon, 4 Dec 2023 16:41:22 +0530 Subject: [PATCH 6/6] Update hook dependency and property type --- src/pages/home/report/ReportActionsList.js | 13 ++++++------- src/types/onyx/ReportAction.ts | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index 8e63f508f8ce9..1836658919292 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -156,7 +156,7 @@ function ReportActionsList({ const readActionSkipped = useRef(false); const hasHeaderRendered = useRef(false); const hasFooterRendered = useRef(false); - const reportActionSize = useRef(sortedReportActions.length); + const lastVisibleActionCreatedRef = useRef(report.lastVisibleActionCreated); const lastReadTimeRef = useRef(report.lastReadTime); const linkedReportActionID = lodashGet(route, 'params.reportActionID', ''); @@ -198,15 +198,15 @@ function ReportActionsList({ } } - if (currentUnreadMarker || reportActionSize.current === sortedReportActions.length) { + if (currentUnreadMarker || lastVisibleActionCreatedRef.current === report.lastVisibleActionCreated) { return; } cacheUnreadMarkers.delete(report.reportID); - reportActionSize.current = sortedReportActions.length; + lastVisibleActionCreatedRef.current = report.lastVisibleActionCreated; setCurrentUnreadMarker(null); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [sortedReportActions.length, report.reportID]); + }, [report.lastVisibleActionCreated, report.reportID]); useEffect(() => { if (!userActiveSince.current || report.reportID !== prevReportID) { @@ -339,10 +339,9 @@ function ReportActionsList({ shouldDisplay = isCurrentMessageUnread && (!nextMessage || !isMessageUnread(nextMessage, lastReadTimeRef.current)); if (shouldDisplay && !messageManuallyMarkedUnread) { const isWithinVisibleThreshold = scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD ? reportAction.created < userActiveSince.current : true; - // Check if the report type is "REPORTREVIEW" and last actor is the current user. - // This is to avoid displaying the new line marker when a current userrequests money. + // Prevent displaying a new marker line when report action is of type "REPORTPREVIEW" and last actor is the current user shouldDisplay = - (ReportActionsUtils.isReportPreviewAction(reportAction) ? !reportAction.childLastActorAccountID : reportAction.actorAccountID !== Report.getCurrentUserAccountID()) && + (ReportActionsUtils.isReportPreviewAction(reportAction) ? !reportAction.childLastActorAccountID : reportAction.actorAccountID) !== Report.getCurrentUserAccountID() && isWithinVisibleThreshold; } if (shouldDisplay) { diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index 64e1eb0b7c882..01d0463abda54 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -115,12 +115,13 @@ type ReportActionBase = { childStateNum?: ValueOf; childLastReceiptTransactionIDs?: string; childLastMoneyRequestComment?: string; + childLastActorAccountID?: number; timestamp?: number; reportActionTimestamp?: number; childMoneyRequestCount?: number; isFirstItem?: boolean; - /** Informations about attachments of report action */ + /** Information about attachments of report action */ attachmentInfo?: (File & {source: string; uri: string}) | Record; /** Receipt tied to report action */