Skip to content

Commit

Permalink
Merge pull request #53555 from bernhardoj/fix/53000-new-msg-marker-sh…
Browse files Browse the repository at this point in the history
…ows-for-system-msg

Fix new message marker shows on a system message in a one-expense report
  • Loading branch information
rafecolton authored Dec 6, 2024
2 parents d0629ce + 8f4ab74 commit 5f143b5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ function ReportActionsList({
return ReportConnection.getReport(report.reportID)?.lastReadTime ?? report.lastReadTime ?? '';
}, [report.reportID, report.lastReadTime]);

// In a one-expense report, the report actions from the expense report and transaction thread are combined.
// If the transaction thread has a newer action, it will show an unread marker if we compare it with the expense report lastReadTime.
// - expense report action A <- expense report lastReadTime
// - transaction thread action A <- transaction thread lastReadTime
// So, we use whichever lastReadTime that is bigger.
const lastReadTime = transactionThreadReport?.lastReadTime && transactionThreadReport.lastReadTime > reportLastReadTime ? transactionThreadReport.lastReadTime : reportLastReadTime;

/**
* The timestamp for the unread marker.
*
Expand All @@ -219,9 +226,9 @@ function ReportActionsList({
* - marks a message as read/unread
* - reads a new message as it is received
*/
const [unreadMarkerTime, setUnreadMarkerTime] = useState(reportLastReadTime);
const [unreadMarkerTime, setUnreadMarkerTime] = useState(lastReadTime);
useEffect(() => {
setUnreadMarkerTime(reportLastReadTime);
setUnreadMarkerTime(lastReadTime);

// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [report.reportID]);
Expand Down

0 comments on commit 5f143b5

Please sign in to comment.