Skip to content
Merged
Changes from all commits
Commits
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
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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining why this is necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!


/**
* 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