Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function MoneyRequestReportActionsList({
}, []);

useEffect(() => {
if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction))) {
if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction, visibleReportActions))) {
// On desktop, when the notification center is displayed, isVisible will return false.
// Currently, there's no programmatic way to dismiss the notification center panel.
// To handle this, we use the 'referrer' parameter to check if the current navigation is triggered from a notification.
Expand Down Expand Up @@ -330,7 +330,7 @@ function MoneyRequestReportActionsList({
// Scan through each visible report action until we find the appropriate action to show the unread marker
for (let index = startIndex; index >= endIndex; index--) {
const reportAction = visibleReportActions.at(index);
const nextAction = visibleReportActions.at(index - 1);
const nextAction = index > 0 ? visibleReportActions.at(index - 1) : undefined;
const isEarliestReceivedOfflineMessage = index === earliestReceivedOfflineMessageIndex;

const shouldDisplayNewMarker =
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1883,9 +1883,9 @@ function isReportActionUnread(reportAction: OnyxEntry<ReportAction>, lastReadTim
* Check whether the current report action of the report is unread or not
*
*/
function isCurrentActionUnread(report: OnyxEntry<Report>, reportAction: ReportAction): boolean {
function isCurrentActionUnread(report: OnyxEntry<Report>, reportAction: ReportAction, visibleReportActions?: ReportAction[]): boolean {
const lastReadTime = report?.lastReadTime ?? '';
const sortedReportActions = getSortedReportActions(Object.values(getAllReportActions(report?.reportID)));
const sortedReportActions = visibleReportActions ?? getSortedReportActions(Object.values(getAllReportActions(report?.reportID)));
const currentActionIndex = sortedReportActions.findIndex((action) => action.reportActionID === reportAction.reportActionID);
if (currentActionIndex === -1) {
return false;
Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ function ReportActionsList({
if (report.reportID !== prevReportID) {
return;
}

if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction))) {
if (isUnread(report, transactionThreadReport) || (lastAction && isCurrentActionUnread(report, lastAction, sortedVisibleReportActions))) {
// On desktop, when the notification center is displayed, isVisible will return false.
// Currently, there's no programmatic way to dismiss the notification center panel.
// To handle this, we use the 'referrer' parameter to check if the current navigation is triggered from a notification.
Expand Down