@@ -62,6 +62,12 @@ type ReportActionsViewProps = {
62
62
/** The reportID of the transaction thread report associated with this current report, if any */
63
63
// eslint-disable-next-line react/no-unused-prop-types
64
64
transactionThreadReportID ?: string | null ;
65
+
66
+ /** If the report has newer actions to load */
67
+ hasNewerActions : boolean ;
68
+
69
+ /** If the report has older actions to load */
70
+ hasOlderActions : boolean ;
65
71
} ;
66
72
67
73
let listOldID = Math . round ( Math . random ( ) * 100 ) ;
@@ -76,6 +82,8 @@ function ReportActionsView({
76
82
isLoadingNewerReportActions = false ,
77
83
hasLoadingNewerReportActionsError = false ,
78
84
transactionThreadReportID,
85
+ hasNewerActions,
86
+ hasOlderActions,
79
87
} : ReportActionsViewProps ) {
80
88
useCopySelectionHelper ( ) ;
81
89
const reactionListRef = useContext ( ReactionListContext ) ;
@@ -253,7 +261,7 @@ function ReportActionsView({
253
261
*/
254
262
const fetchNewerAction = useCallback (
255
263
( newestReportAction : OnyxTypes . ReportAction ) => {
256
- if ( isLoadingNewerReportActions || isLoadingInitialReportActions || ( reportActionID && isOffline ) ) {
264
+ if ( ! hasNewerActions || isLoadingNewerReportActions || isLoadingInitialReportActions || ( reportActionID && isOffline ) ) {
257
265
return ;
258
266
}
259
267
@@ -270,7 +278,7 @@ function ReportActionsView({
270
278
Report . getNewerActions ( reportID , newestReportAction . reportActionID ) ;
271
279
}
272
280
} ,
273
- [ isLoadingNewerReportActions , isLoadingInitialReportActions , reportActionID , isOffline , transactionThreadReport , reportActionIDMap , reportID ] ,
281
+ [ isLoadingNewerReportActions , isLoadingInitialReportActions , reportActionID , isOffline , transactionThreadReport , reportActionIDMap , reportID , hasNewerActions ] ,
274
282
) ;
275
283
276
284
const hasMoreCached = reportActions . length < combinedReportActions . length ;
@@ -279,7 +287,6 @@ function ReportActionsView({
279
287
const hasCachedActionOnFirstRender = useInitialValue ( ( ) => reportActions . length > 0 ) ;
280
288
const hasNewestReportAction = reportActions . at ( 0 ) ?. created === report . lastVisibleActionCreated || reportActions . at ( 0 ) ?. created === transactionThreadReport ?. lastVisibleActionCreated ;
281
289
const oldestReportAction = useMemo ( ( ) => reportActions ?. at ( - 1 ) , [ reportActions ] ) ;
282
- const hasCreatedAction = oldestReportAction ?. actionName === CONST . REPORT . ACTIONS . TYPE . CREATED ;
283
290
284
291
useEffect ( ( ) => {
285
292
const wasLoginChangedDetected = prevAuthTokenType === CONST . AUTH_TOKEN_TYPES . ANONYMOUS && ! session ?. authTokenType ;
@@ -343,7 +350,7 @@ function ReportActionsView({
343
350
}
344
351
345
352
// Don't load more chats if we're already at the beginning of the chat history
346
- if ( ! oldestReportAction || hasCreatedAction ) {
353
+ if ( ! oldestReportAction || ! hasOlderActions ) {
347
354
return ;
348
355
}
349
356
@@ -367,11 +374,11 @@ function ReportActionsView({
367
374
isLoadingOlderReportActions ,
368
375
isLoadingInitialReportActions ,
369
376
oldestReportAction ,
370
- hasCreatedAction ,
371
377
reportID ,
372
378
reportActionIDMap ,
373
379
transactionThreadReport ,
374
380
hasLoadingOlderReportActionsError ,
381
+ hasOlderActions ,
375
382
] ,
376
383
) ;
377
384
@@ -524,6 +531,14 @@ function arePropsEqual(oldProps: ReportActionsViewProps, newProps: ReportActions
524
531
return false ;
525
532
}
526
533
534
+ if ( oldProps . hasNewerActions !== newProps . hasNewerActions ) {
535
+ return false ;
536
+ }
537
+
538
+ if ( oldProps . hasOlderActions !== newProps . hasOlderActions ) {
539
+ return false ;
540
+ }
541
+
527
542
return lodashIsEqual ( oldProps . report , newProps . report ) ;
528
543
}
529
544
0 commit comments