Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d0c9c56
Gate unread markers by report
deetergp Sep 8, 2026
50b756f
Test read report markers
deetergp Sep 8, 2026
68c6b42
Preserve unread marker on open
deetergp Sep 10, 2026
9892d62
Merge remote-tracking branch 'origin/main' into deetergp/677837-hide-…
deetergp Sep 10, 2026
e18f08b
Merge remote-tracking branch 'origin/main' into deetergp/677837-hide-…
deetergp Sep 10, 2026
d41461e
Test money request unread marker
deetergp Sep 10, 2026
33e1ac1
Format merged main files
deetergp Sep 10, 2026
686e442
Format merged main files
deetergp Sep 10, 2026
f59496e
Fix unread marker test mock
deetergp Sep 10, 2026
11af967
Remove unread marker test mock
deetergp Sep 10, 2026
b17ec05
Test money request marker state
deetergp Sep 10, 2026
a538732
Type unread marker test mock
deetergp Sep 10, 2026
98d3973
Type marker test module mock
deetergp Sep 10, 2026
9766d55
Filter non-actionable markers
deetergp Sep 14, 2026
fe80596
Test marker actionability
deetergp Sep 14, 2026
97ccc8d
Merge branch 'main' into deetergp/677837-hide-read-markers
deetergp Sep 14, 2026
6537ae2
Merge remote-tracking branch 'origin/main' into deetergp/677837-hide-…
deetergp Sep 16, 2026
214d9f5
Filter unread pagination anchors
deetergp Sep 19, 2026
7917012
Preserve reversed Concierge markers
deetergp Sep 19, 2026
e481225
Exclude export actions from unread markers
deetergp Sep 19, 2026
b96be5a
Advance filtered offline marker boundaries
deetergp Sep 19, 2026
be61f94
Honor manual unread marker anchors
deetergp Sep 19, 2026
281ea71
Preserve unread markers after filtered offline activity
deetergp Oct 7, 2026
1ce0048
Complete deferred reads when scrolling to the end
deetergp Oct 7, 2026
c358062
Keep manual unread anchoring in the scanner
deetergp Oct 7, 2026
9648f57
Scan eligible unread actions once
deetergp Oct 7, 2026
eefb330
Explain unread marker eligibility and boundaries
deetergp Oct 7, 2026
e2aefba
Share unread marker eligibility from report action utilities
deetergp Oct 7, 2026
d9e4979
Cover manual anchors and legacy reimbursement markers
deetergp Oct 7, 2026
fe868ef
Derive offline unread boundaries from eligible received actions
deetergp Oct 8, 2026
15d6383
Merge remote-tracking branch 'origin/main' into deetergp/677837-hide-…
deetergp Oct 13, 2026
01f461b
Supply report drafts in split-expense test fixtures
deetergp Oct 13, 2026
745b221
Merge remote-tracking branch 'origin/main' into deetergp/677837-hide-…
deetergp Oct 13, 2026
64e3004
Honor report-level manual unread anchors
deetergp Oct 16, 2026
d16965c
Align manual report anchors with the unread boundary
deetergp Oct 19, 2026
e64a490
Honor inbox mark-as-unread commands
deetergp Oct 19, 2026
e4190d8
Cover inbox mark-as-unread regressions
deetergp Oct 19, 2026
dbbdba5
Clear manual unread markers on explicit reads
deetergp Oct 19, 2026
072d54e
Cover explicit mark-as-read marker clearing
deetergp Oct 19, 2026
1859cfc
Expire consumed manual unread anchors on return
deetergp Oct 22, 2026
af0b8a7
Cover manual unread marker return visits
deetergp Oct 22, 2026
ce5e9f8
Limit manual unread state to the marked cursor
deetergp Oct 22, 2026
df8c4da
Cover consumed manual unread state
deetergp Oct 22, 2026
90125aa
Merge origin/main and preserve unread marker fixes
deetergp Oct 28, 2026
e097629
Limit automatic unread markers to payment recipients and exclude NetS…
deetergp Oct 30, 2026
5521c6d
Cover scoped payment and NetSuite unread marker filtering
deetergp Oct 30, 2026
db1dfe6
Narrow unread-marker PR to the original system-message scope
deetergp Oct 30, 2026
c4f271c
Merge main to refresh the scoped unread-marker PR comparison
deetergp Oct 30, 2026
ed6732a
Merge main into scoped system-message unread fix
deetergp Nov 3, 2026
461406d
Choose an eligible message when marking a chat unread
deetergp Nov 4, 2026
00b2987
Test chat unread marks beside filtered system messages
deetergp Nov 4, 2026
52baf45
Complete a skipped read after scrolling down without a divider
deetergp Nov 4, 2026
92b40ef
Test skipped reads when no unread divider is shown
deetergp Nov 4, 2026
5db060e
Merge main and update unread-marker test message fixtures
deetergp Nov 10, 2026
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
19 changes: 14 additions & 5 deletions src/hooks/useUnreadMarker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isReportActionFromCurrentUser, wasMessageReceivedWhileOffline} from '@libs/ReportActionsUtils';
import {canReportActionTriggerUnreadMarker, isReportActionFromCurrentUser, wasMessageReceivedWhileOffline} from '@libs/ReportActionsUtils';
import Visibility from '@libs/Visibility';

import {getUnreadMarkerReportAction} from '@pages/inbox/report/shouldDisplayNewMarkerOnReportAction';
Expand Down Expand Up @@ -114,7 +114,11 @@ function useUnreadMarker({
const offlineScanStep = isReversed ? 1 : -1;
for (let i = offlineScanStartIndex; i >= 0 && i < offlineBoundaryActions.length; i += offlineScanStep) {
const message = offlineBoundaryActions.at(i);
if (message && wasMessageReceivedWhileOffline(message, isOffline, lastOfflineAt.current, lastOnlineAt.current, getLocalDateFromDatetime, currentUserAccountID)) {
if (
message &&
canReportActionTriggerUnreadMarker(message, currentUserAccountID) &&
wasMessageReceivedWhileOffline(message, isOffline, lastOfflineAt.current, lastOnlineAt.current, getLocalDateFromDatetime, currentUserAccountID)
) {
earliestReceivedOfflineMessageIndex = i;
break;
}
Expand All @@ -124,9 +128,14 @@ function useUnreadMarker({
let oldestUnreadReportActionMarker: [string, number] | undefined;
if (oldestUnreadReportActionID && !hasOnceLoadedReportActions) {
const visibleIndex = sortedVisibleReportActions.findIndex((action) => action.reportActionID === oldestUnreadReportActionID);
// A stale lastReadTime can make a message sent by the current user on another device the pagination anchor.
// Use the scan result instead when the current user authored that action.
if (visibleIndex >= 0 && !isReportActionFromCurrentUser(sortedVisibleReportActions.at(visibleIndex), currentUserAccountID)) {
const visibleAction = visibleIndex >= 0 ? sortedVisibleReportActions.at(visibleIndex) : undefined;
// Pagination must not bypass the current-user or informational-message checks.
if (
visibleIndex >= 0 &&
visibleAction &&
!isReportActionFromCurrentUser(visibleAction, currentUserAccountID) &&
canReportActionTriggerUnreadMarker(visibleAction, currentUserAccountID)
) {
oldestUnreadReportActionMarker = [oldestUnreadReportActionID, visibleIndex];
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,16 @@ function shouldReportActionBeVisible(
return !!reportAction.pendingAction || !isDeletedAction(reportAction) || isDeletedParentAction(reportAction) || isReversedTransaction(reportAction);
}

/** Whether an action can automatically create an unread divider for this account. */
function canReportActionTriggerUnreadMarker(reportAction: ReportAction, currentUserAccountID: number): boolean {
if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.REIMBURSED)) {
const recipients = getOriginalMessage(reportAction)?.actionableForAccountIDs;
// Older actions have no recipient metadata, so preserve their existing behavior.
return !recipients || recipients.includes(currentUserAccountID);
}
return !(isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) && getOriginalMessage(reportAction)?.label === CONST.EXPORT_LABELS.NETSUITE);
}

/**
* Checks if the new marker should be hidden for the report action.
*/
Expand Down Expand Up @@ -6316,6 +6326,7 @@ export {
isResolvedActionableWhisper,
isReimbursementDirectionInformationRequiredAction,
shouldHideNewMarker,
canReportActionTriggerUnreadMarker,
shouldReportActionBeVisible,
isReportActionVisible,
wasActionTakenByCurrentUser,
Expand Down
18 changes: 9 additions & 9 deletions src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3396,18 +3396,18 @@ function markCommentAsUnread(reportID: string | undefined, reportActions: OnyxEn
}

// Find the latest report actions from other users
const latestReportActionFromOtherUsers = Object.values(reportActions ?? {}).reduce((latest: ReportAction | null, current: ReportAction) => {
if (
const reportActionsFromOtherUsers = Object.values(reportActions ?? {}).filter(
(current) =>
!ReportActionsUtils.isDeletedAction(current) &&
current.actorAccountID !== currentUserAccountID &&
(!latest || current.created > latest.created) &&
// Whisper action doesn't affect lastVisibleActionCreated, so skip whisper action except actionable mention whisper
(!ReportActionsUtils.isWhisperAction(current) || current.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER)
) {
return current;
}
return latest;
}, null);
(!ReportActionsUtils.isWhisperAction(current) || current.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER),
);
const eligibleReportActions = reportAction?.created
? reportActionsFromOtherUsers
: reportActionsFromOtherUsers.filter((action) => ReportActionsUtils.canReportActionTriggerUnreadMarker(action, currentUserAccountID));
const unreadCandidates = eligibleReportActions.length > 0 ? eligibleReportActions : reportActionsFromOtherUsers;
const latestReportActionFromOtherUsers = unreadCandidates.reduce((latest: ReportAction | null, current) => (!latest || current.created > latest.created ? current : latest), null);

const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`];
Expand Down
20 changes: 12 additions & 8 deletions src/pages/inbox/report/shouldDisplayNewMarkerOnReportAction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isReportActionFromCurrentUser, isReportActionUnread, shouldHideNewMarker} from '@libs/ReportActionsUtils';
import {canReportActionTriggerUnreadMarker, isReportActionFromCurrentUser, isReportActionUnread, shouldHideNewMarker} from '@libs/ReportActionsUtils';

import CONST from '@src/CONST';
import type * as OnyxTypes from '@src/types/onyx';
Expand Down Expand Up @@ -210,17 +210,21 @@ const getUnreadMarkerReportAction = ({
for (let index = startIndex; isReversed ? index >= endIndex : index < endIndex; index += step) {
const reportAction = visibleReportActions.at(index);

if (!isReversed && reportAction?.reportActionID === CONST.CONCIERGE_GREETING_ACTION_ID) {
if (
!reportAction ||
(!isReversed && reportAction.reportActionID === CONST.CONCIERGE_GREETING_ACTION_ID) ||
(!activeManuallyMarkedUnreadReportActionID && !canReportActionTriggerUnreadMarker(reportAction, currentUserAccountID))
) {
continue;
}

let nextAction: OnyxTypes.ReportAction | undefined;
if (isReversed) {
nextAction = index > 0 ? visibleReportActions.at(index - 1) : undefined;
} else {
nextAction = visibleReportActions.at(index + 1);
if (nextAction?.reportActionID === CONST.CONCIERGE_GREETING_ACTION_ID) {
nextAction = visibleReportActions.at(index + 2);
// Informational messages must not hide a real unread message beside them.
for (let nextIndex = index + step; isReversed ? nextIndex >= endIndex : nextIndex < endIndex; nextIndex += step) {
const candidate = visibleReportActions.at(nextIndex);
if (candidate && (isReversed || candidate.reportActionID !== CONST.CONCIERGE_GREETING_ACTION_ID) && canReportActionTriggerUnreadMarker(candidate, currentUserAccountID)) {
nextAction = candidate;
break;
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/pages/inbox/report/useReportUnreadMessageScrollTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ export default function useReportUnreadMessageScrollTracking({
}

updatePillVisibility();

// Without a divider, reaching the newest messages must still finish a skipped read.
if (
event &&
ref.current.isFocused &&
unreadMarkerReportActionIndex === -1 &&
!hasNewerActions &&
currentVerticalScrollingOffsetRef.current < CONST.REPORT.ACTIONS.ACTION_VISIBLE_THRESHOLD
) {
ref.current.onUnreadActionVisible();
}
};

const onViewableItemsChanged = ({viewableItems}: {viewableItems: ViewToken[]; changed: ViewToken[]}) => {
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,9 @@ type OriginalMessageMarkedReimbursed = {

/** Model of `reimbursed` report action */
type OriginalMessageReimbursed = {
/** Accounts the payment message is actionable for, supplied by Auth. */
actionableForAccountIDs?: number[];

/** Whether this action was created from NewDot */
isNewDot?: boolean;

Expand Down
92 changes: 92 additions & 0 deletions tests/actions/ReportTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,98 @@ describe('actions/Report', () => {
return setPromise;
});

describe.each([
{
name: 'a NetSuite export',
actionName: CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION,
originalMessage: {label: CONST.EXPORT_LABELS.NETSUITE, lastModified: '2023-01-01 12:00:00.000'},
},
{
name: 'a payment meant for someone else',
actionName: CONST.REPORT.ACTIONS.TYPE.REIMBURSED,
originalMessage: {actionableForAccountIDs: [3]},
},
])('marking unread with $name', ({actionName, originalMessage}) => {
const reportID = 'scoped-unread';
const currentUserAccountID = 1;
const comment = createMock<OnyxTypes.ReportAction>({
reportActionID: 'comment',
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
actorAccountID: 2,
created: '2023-01-01 11:00:00.000',
message: [{type: 'COMMENT', text: 'An ordinary comment', html: 'An ordinary comment'}],
});
const informational = createMock<OnyxTypes.ReportAction>({
reportActionID: 'informational',
actionName,
originalMessage,
actorAccountID: 2,
created: '2023-01-01 12:00:00.000',
message: [{type: 'COMMENT', text: 'System message', html: 'System message'}],
});

beforeEach(async () => {
apiWriteSpy.mockResolvedValue(undefined);
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {
reportID,
type: CONST.REPORT.TYPE.CHAT,
lastVisibleActionCreated: informational.created,
lastReadTime: informational.created,
lastActorAccountID: informational.actorAccountID,
});
await waitForBatchedUpdates();
});

it('uses the newest eligible message when marking the whole chat unread', () => {
// Given a read chat whose newest activity cannot show an automatic divider
const reportActions = {comment, informational};

// When the user marks the chat unread without choosing a specific message
Report.markCommentAsUnread(reportID, reportActions, createMock<OnyxTypes.ReportAction>({}), currentUserAccountID, false);

// Then the read time points to the ordinary comment without storing a manual message anchor
expect(apiWriteSpy).toHaveBeenCalledWith(
WRITE_COMMANDS.MARK_AS_UNREAD,
expect.objectContaining({reportActionID: comment.reportActionID, lastReadTime: DateUtils.subtractMillisecondsFromDateTime(comment.created, 1)}),
expect.objectContaining({
optimisticData: expect.arrayContaining([expect.objectContaining({value: expect.objectContaining({manuallyMarkedUnreadReportActionID: null})})]),
}),
);
});

it('keeps a specific message unread even when automatic dividers are filtered', () => {
// Given the same system message and an older ordinary comment
const reportActions = {comment, informational};

// When the user explicitly marks the system message unread
Report.markCommentAsUnread(reportID, reportActions, informational, currentUserAccountID, false);

// Then the chosen message still supplies the read time and manual anchor
expect(apiWriteSpy).toHaveBeenCalledWith(
WRITE_COMMANDS.MARK_AS_UNREAD,
expect.objectContaining({reportActionID: informational.reportActionID, lastReadTime: DateUtils.subtractMillisecondsFromDateTime(informational.created, 1)}),
expect.objectContaining({
optimisticData: expect.arrayContaining([expect.objectContaining({value: expect.objectContaining({manuallyMarkedUnreadReportActionID: informational.reportActionID})})]),
}),
);
});

it('keeps the existing fallback when no eligible message from another user exists', () => {
// Given only filtered activity from another user and a newer comment from the current user
const ownComment = {...comment, actorAccountID: currentUserAccountID, created: '2023-01-01 13:00:00.000'};

// When the whole chat is marked unread
Report.markCommentAsUnread(reportID, {ownComment, informational}, createMock<OnyxTypes.ReportAction>({}), currentUserAccountID, false);

// Then the system message still supplies the fallback rather than the user's own comment
expect(apiWriteSpy).toHaveBeenCalledWith(
WRITE_COMMANDS.MARK_AS_UNREAD,
expect.objectContaining({reportActionID: informational.reportActionID, lastReadTime: DateUtils.subtractMillisecondsFromDateTime(informational.created, 1)}),
expect.anything(),
);
});
});

it('Should properly update comment with links', async () => {
/* This tests a variety of scenarios when a user edits a comment.
* We should generate a link when editing a message unless the link was
Expand Down
60 changes: 60 additions & 0 deletions tests/unit/ReportActionsUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8113,6 +8113,66 @@ describe('ReportActionsUtils', () => {
isReversed: false,
};

it.each([
{actionName: CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION, originalMessage: {label: CONST.EXPORT_LABELS.NETSUITE, lastModified: '2023-01-01 11:00:00.000'}, expected: null},
{
actionName: CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION,
originalMessage: {label: CONST.EXPORT_LABELS.QBO, lastModified: '2023-01-01 11:00:00.000'},
expected: 'system-action',
},
{actionName: CONST.REPORT.ACTIONS.TYPE.REIMBURSED, originalMessage: {actionableForAccountIDs: [currentUserAccountID]}, expected: 'system-action'},
{actionName: CONST.REPORT.ACTIONS.TYPE.REIMBURSED, originalMessage: {actionableForAccountIDs: [99]}, expected: null},
{actionName: CONST.REPORT.ACTIONS.TYPE.REIMBURSED, originalMessage: {}, expected: 'system-action'},
])('limits automatic markers for $actionName with $originalMessage', ({actionName, originalMessage, expected}) => {
// Given an unread system action, including legacy reimbursements without recipient metadata
const action = makeAction({reportActionID: 'system-action', actionName, originalMessage});

// When scanning online or offline in either list direction
for (const isOffline of [false, true]) {
for (const isReversed of [false, true]) {
// Then only NetSuite exports and reimbursements targeted to someone else are suppressed
expect(getUnreadMarkerReportAction({...baseScanParams, visibleReportActions: [action], isOffline, isReversed})).toEqual([expected, expected ? 0 : -1]);
}
}
});

it.each([
{actionName: CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION, originalMessage: {label: CONST.EXPORT_LABELS.NETSUITE, lastModified: '2023-01-01 11:00:00.000'}},
{actionName: CONST.REPORT.ACTIONS.TYPE.REIMBURSED, originalMessage: {actionableForAccountIDs: [99]}},
])('skips informational $actionName without hiding a real unread message', ({actionName, originalMessage}) => {
// Given a real unread comment next to a filtered informational action
const comment = makeAction({reportActionID: 'comment', created: '2023-01-01 12:00:00.000'});
const informational = makeAction({reportActionID: 'informational', actionName, originalMessage});
const read = makeAction({reportActionID: 'read', created: '2023-01-01 09:00:00.000'});

// When the informational action falls before or after the comment in either list direction
for (const informationalIsNewer of [false, true]) {
const filtered = {...informational, created: informationalIsNewer ? '2023-01-01 13:00:00.000' : informational.created};
const newestFirst = informationalIsNewer ? [filtered, comment, read] : [comment, filtered, read];
for (const isReversed of [false, true]) {
const actions = isReversed ? [...newestFirst].reverse() : newestFirst;
// Then the real comment keeps the divider at its original list index
expect(getUnreadMarkerReportAction({...baseScanParams, visibleReportActions: actions, isReversed})).toEqual(['comment', actions.indexOf(comment)]);
}
}
});

it('preserves the existing explicit message-level unread override for a NetSuite export', () => {
// Given a NetSuite export explicitly marked unread by the user
const action = makeAction({
reportActionID: 'manual-export',
actionName: CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION,
originalMessage: {label: CONST.EXPORT_LABELS.NETSUITE, lastModified: '2023-01-01 11:00:00.000'},
});

// When scanning with the manual anchor main already stores
// Then automatic filtering must not change that explicit message-level command
expect(getUnreadMarkerReportAction({...baseScanParams, visibleReportActions: [action], manuallyMarkedUnreadReportActionID: action.reportActionID})).toEqual([
action.reportActionID,
0,
]);
});

it('short-circuits to [null, -1] for an anonymous user', () => {
const visibleReportActions = [makeAction({reportActionID: 'a'})];
expect(
Expand Down
Loading
Loading