Skip to content

Commit 9c7b785

Browse files
committed
Revert "Mark the report as read after scrolling to the user's own comment"
This reverts commit 654e67a.
1 parent 030fc18 commit 9c7b785

3 files changed

Lines changed: 1 addition & 39 deletions

File tree

‎src/hooks/useReportActionsScroll.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ function useReportActionsScroll({
242242
reportScrollManager,
243243
setIsFloatingMessageCounterVisible,
244244
setActionIdToHighlight,
245-
markNewestActionAsRead,
246245
unreadMarkerReportActionID,
247246
hasNewerActions,
248247
linkedReportActionID,

‎src/pages/inbox/report/useReportActionsNewActionLiveTail.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ type UseReportActionsNewActionLiveTailParams = {
4343
reportScrollManager: ReportScrollManager;
4444
setIsFloatingMessageCounterVisible: (visible: boolean) => void;
4545
setActionIdToHighlight: (actionID: string) => void;
46-
markNewestActionAsRead: () => void;
4746
unreadMarkerReportActionID: string | null;
4847
hasNewerActions: boolean;
4948
linkedReportActionID: string | undefined;
@@ -75,7 +74,6 @@ function useReportActionsNewActionLiveTail({
7574
reportScrollManager,
7675
setIsFloatingMessageCounterVisible,
7776
setActionIdToHighlight,
78-
markNewestActionAsRead,
7977
unreadMarkerReportActionID,
8078
hasNewerActions,
8179
linkedReportActionID,
@@ -94,12 +92,6 @@ function useReportActionsNewActionLiveTail({
9492
const liveTailJumpRef = useRef<{stage: LiveTailJumpStage}>({stage: 'idle'});
9593
const [isScrollToBottomEnabled, setIsScrollToBottomEnabled] = useState(false);
9694

97-
// Scrolling to the user's own comment must also mark the report as read. Otherwise the "New" divider stays, and the
98-
// unread marker it leaves behind turns the "New messages" pill back on. An effect event keeps it out of effect deps.
99-
const markAsReadAfterScroll = useEffectEvent(() => {
100-
markNewestActionAsRead();
101-
});
102-
10395
const scrollToBottomForCurrentUserAction = useEffectEvent((isFromCurrentUser: boolean, action?: OnyxTypes.ReportAction) => {
10496
TransitionTracker.runAfterTransitions({
10597
callback: () => {
@@ -148,7 +140,6 @@ function useReportActionsNewActionLiveTail({
148140
} else {
149141
setIsFloatingMessageCounterVisible(false);
150142
reportScrollManager.scrollToBottom();
151-
markAsReadAfterScroll();
152143
}
153144

154145
setIsScrollToBottomEnabled(true);
@@ -206,7 +197,6 @@ function useReportActionsNewActionLiveTail({
206197

207198
liveTailJumpRef.current = {stage: 'await_prune'};
208199
setIsFloatingMessageCounterVisible(false);
209-
markAsReadAfterScroll();
210200
// Defer so this effect does not synchronously chain a second render from setState (eslint react-hooks/set-state-in-effect).
211201
queueMicrotask(() => {
212202
setIsScrollToBottomEnabled(true);

‎tests/unit/useReportActionsNewActionLiveTailTest.ts‎

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ function buildParams(overrides: Partial<HookParams> = {}): HookParams {
9999
reportScrollManager,
100100
setIsFloatingMessageCounterVisible: jest.fn(),
101101
setActionIdToHighlight: jest.fn(),
102-
markNewestActionAsRead: jest.fn(),
103102
unreadMarkerReportActionID: null,
104103
hasNewerActions: true,
105104
linkedReportActionID: undefined,
@@ -214,9 +213,8 @@ describe('useReportActionsNewActionLiveTail', () => {
214213
it('scrolls straight to the bottom when an unread marker is set but the newest actions are already loaded', () => {
215214
// Given a report scrolled up with an unread marker from another user's comment, and the newest actions already loaded
216215
const setIsFloatingMessageCounterVisible = jest.fn();
217-
const markNewestActionAsRead = jest.fn();
218216
const {result} = renderHook((props: HookParams) => useReportActionsNewActionLiveTail(props), {
219-
initialProps: buildParams({unreadMarkerReportActionID: '2', hasNewerActions: false, hasNewestReportAction: true, setIsFloatingMessageCounterVisible, markNewestActionAsRead}),
217+
initialProps: buildParams({unreadMarkerReportActionID: '2', hasNewerActions: false, hasNewestReportAction: true, setIsFloatingMessageCounterVisible}),
220218
});
221219

222220
// When the current user sends a comment
@@ -229,31 +227,6 @@ describe('useReportActionsNewActionLiveTail', () => {
229227
expect(setIsFloatingMessageCounterVisible).toHaveBeenCalledWith(false);
230228
expect(reportScrollManager.scrollToBottom).toHaveBeenCalledTimes(1);
231229
expect(result.current.isScrollToBottomEnabled).toBe(true);
232-
233-
// And the report is marked as read, so the "New" divider clears and the pill doesn't come back
234-
expect(markNewestActionAsRead).toHaveBeenCalledTimes(1);
235-
});
236-
237-
it('marks the report as read once openReport has loaded the newest actions after the user sends a comment', () => {
238-
// Given a report whose newest actions are not loaded yet
239-
const markNewestActionAsRead = jest.fn();
240-
const {rerender} = renderHook((props: HookParams) => useReportActionsNewActionLiveTail(props), {initialProps: buildParams({markNewestActionAsRead})});
241-
242-
// When the current user sends a comment, which starts the live-tail jump through openReport
243-
act(() => {
244-
newActionHandler?.(true, getFakeReportAction(1, {actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT}));
245-
});
246-
247-
// Then nothing is marked as read while the newest actions are still loading
248-
expect(mockOpenReport).toHaveBeenCalledTimes(1);
249-
expect(markNewestActionAsRead).not.toHaveBeenCalled();
250-
251-
// When openReport finishes and the newest actions arrive
252-
rerender(buildParams({markNewestActionAsRead, prevIsLoadingInitialReportActions: true, reportLoadingState: {isLoadingInitialReportActions: false}}));
253-
rerender(buildParams({markNewestActionAsRead, prevIsLoadingInitialReportActions: false, reportLoadingState: {isLoadingInitialReportActions: false}, hasNewestReportAction: true}));
254-
255-
// Then the report is marked as read once, alongside hiding the pill
256-
expect(markNewestActionAsRead).toHaveBeenCalledTimes(1);
257230
});
258231

259232
it('still loads the live tail when an unread marker is set and the newest actions are not loaded', () => {

0 commit comments

Comments
 (0)