Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new message marker shows on a system message in a one-expense report #53555

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
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
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
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
Loading