@@ -61,6 +61,9 @@ const propTypes = {
61
61
62
62
/** Flag to check if the report actions data are loading */
63
63
isLoadingReportActions : PropTypes . bool ,
64
+
65
+ /** ID for the report */
66
+ reportID : PropTypes . string ,
64
67
} ) ,
65
68
66
69
/** Array of report actions for this report */
@@ -165,22 +168,31 @@ class ReportScreen extends React.Component {
165
168
shouldShowLoader ( ) {
166
169
// This means there are no reportActions at all to display, but it is still in the process of loading the next set of actions.
167
170
const isLoadingInitialReportActions = _ . isEmpty ( this . props . reportActions ) && this . props . report . isLoadingReportActions ;
168
- return ! getReportID ( this . props . route ) || isLoadingInitialReportActions ;
171
+ return ! getReportID ( this . props . route ) || isLoadingInitialReportActions || ! this . props . report . reportID ;
169
172
}
170
173
171
174
/**
172
175
* Persists the currently viewed report id
173
176
*/
174
177
storeCurrentlyViewedReport ( ) {
175
- const reportID = getReportID ( this . props . route ) ;
176
- if ( _ . isNaN ( reportID ) ) {
178
+ const reportIDFromPath = getReportID ( this . props . route ) ;
179
+ if ( _ . isNaN ( reportIDFromPath ) ) {
177
180
Report . handleInaccessibleReport ( ) ;
178
181
return ;
179
182
}
180
183
181
184
// Always reset the state of the composer view when the current reportID changes
182
185
toggleReportActionComposeView ( true ) ;
183
- Report . updateCurrentlyViewedReportID ( reportID ) ;
186
+ Report . updateCurrentlyViewedReportID ( reportIDFromPath ) ;
187
+
188
+ // It possible that we may not have the report object yet in Onyx yet e.g. we navigated to a URL for an accessible report that
189
+ // is not stored locally yet. If props.report.reportID exists, then the report has been stored locally and nothing more needs to be done.
190
+ // If it doesn't exist, then we fetch the report from the API.
191
+ if ( this . props . report . reportID ) {
192
+ return ;
193
+ }
194
+
195
+ Report . fetchChatReportsByIDs ( [ reportIDFromPath ] , true ) ;
184
196
}
185
197
186
198
/**
0 commit comments