diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index 8e63f508f8ce..183665891929 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 64e1eb0b7c88..01d0463abda5 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 */