@@ -100,7 +100,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe
100
100
101
101
const transactionThreadReportID = getOneTransactionThreadReportID ( reportID , reportActions ?? [ ] , isOffline ) ;
102
102
103
- const [ transactions = undefined ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION , {
103
+ const [ transactions ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION , {
104
104
selector : ( allTransactions : OnyxCollection < OnyxTypes . Transaction > ) => selectAllTransactionsForReport ( allTransactions , reportID , reportActions ) ,
105
105
canBeMissing : true ,
106
106
} ) ;
@@ -123,8 +123,14 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe
123
123
// If true we will use standard `ReportActionsView` to display report data and a special header, anything else is handled via `MoneyRequestReportActionsList`
124
124
const isTransactionThreadView = isReportTransactionThread ( report ) ;
125
125
126
- const isEmptyTransactionReport = transactions && transactionThreadReportID === undefined && ! isLoadingInitialReportActions ;
127
- const shouldDisplayMoneyRequestActionsList = ! ! isEmptyTransactionReport && shouldDisplayReportTableView ( report , transactions ) ;
126
+ // Prevent flash by ensuring transaction data is fully loaded before deciding which view to render
127
+ // We need to wait for both the selector to finish AND ensure we're not in a loading state where transactions could still populate
128
+ const isTransactionDataReady = transactions !== undefined ;
129
+ const isStillLoadingData = ! ! isLoadingInitialReportActions || ! ! reportMetadata ?. isLoadingOlderReportActions || ! ! reportMetadata ?. isLoadingNewerReportActions ;
130
+ const shouldWaitForData = ( ! isTransactionDataReady || ( isStillLoadingData && transactions ?. length === 0 ) ) && ! isTransactionThreadView ;
131
+
132
+ const isEmptyTransactionReport = transactions && transactions . length === 0 && transactionThreadReportID === undefined ;
133
+ const shouldDisplayMoneyRequestActionsList = ! ! isEmptyTransactionReport || shouldDisplayReportTableView ( report , transactions ?? [ ] ) ;
128
134
129
135
const reportHeaderView = useMemo (
130
136
( ) =>
@@ -160,7 +166,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe
160
166
[ activeWorkspaceID , backToRoute , isTransactionThreadView , parentReportAction , policy , report , reportActions , transactionThreadReportID ] ,
161
167
) ;
162
168
163
- if ( ! ! ( isLoadingInitialReportActions && reportActions . length === 0 && ! isOffline ) || ! transactions ) {
169
+ if ( ! ! ( isLoadingInitialReportActions && reportActions . length === 0 && ! isOffline ) || shouldWaitForData ) {
164
170
return < InitialLoadingSkeleton styles = { styles } /> ;
165
171
}
166
172
@@ -214,6 +220,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe
214
220
reportActions = { reportActions }
215
221
hasOlderActions = { hasOlderActions }
216
222
hasNewerActions = { hasNewerActions }
223
+ isLoadingInitialReportActions = { isLoadingInitialReportActions }
217
224
/>
218
225
) : (
219
226
< ReportActionsView
0 commit comments