@@ -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 [ 0 ] ?. created === report . lastVisibleActionCreated || reportActions [ 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 ;
@@ -341,7 +348,7 @@ function ReportActionsView({
341
348
}
342
349
343
350
// Don't load more chats if we're already at the beginning of the chat history
344
- if ( ! oldestReportAction || hasCreatedAction ) {
351
+ if ( ! oldestReportAction || ! hasOlderActions ) {
345
352
return ;
346
353
}
347
354
@@ -365,11 +372,11 @@ function ReportActionsView({
365
372
isLoadingOlderReportActions ,
366
373
isLoadingInitialReportActions ,
367
374
oldestReportAction ,
368
- hasCreatedAction ,
369
375
reportID ,
370
376
reportActionIDMap ,
371
377
transactionThreadReport ,
372
378
hasLoadingOlderReportActionsError ,
379
+ hasOlderActions ,
373
380
] ,
374
381
) ;
375
382
@@ -522,6 +529,14 @@ function arePropsEqual(oldProps: ReportActionsViewProps, newProps: ReportActions
522
529
return false ;
523
530
}
524
531
532
+ if ( oldProps . hasNewerActions !== newProps . hasNewerActions ) {
533
+ return false ;
534
+ }
535
+
536
+ if ( oldProps . hasOlderActions !== newProps . hasOlderActions ) {
537
+ return false ;
538
+ }
539
+
525
540
return lodashIsEqual ( oldProps . report , newProps . report ) ;
526
541
}
527
542
0 commit comments