@@ -17,6 +17,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
17
17
import * as Report from '@libs/actions/Report' ;
18
18
import * as DeviceCapabilities from '@libs/DeviceCapabilities' ;
19
19
import * as OptionsListUtils from '@libs/OptionsListUtils' ;
20
+ import * as ReportUtils from '@libs/ReportUtils' ;
20
21
import reportPropTypes from '@pages/reportPropTypes' ;
21
22
import CONST from '@src/CONST' ;
22
23
import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -54,16 +55,16 @@ const propTypes = {
54
55
/** The request type, ie. manual, scan, distance */
55
56
iouRequestType : PropTypes . oneOf ( _ . values ( CONST . IOU . REQUEST_TYPE ) ) . isRequired ,
56
57
57
- /** Whether we are searching for reports in the server */
58
- isSearchingForReports : PropTypes . bool ,
58
+ /** Whether the parent screen transition has ended */
59
+ didScreenTransitionEnd : PropTypes . bool ,
59
60
} ;
60
61
61
62
const defaultProps = {
62
63
participants : [ ] ,
63
64
safeAreaPaddingBottomStyle : { } ,
64
65
reports : { } ,
65
66
betas : [ ] ,
66
- isSearchingForReports : false ,
67
+ didScreenTransitionEnd : false ,
67
68
} ;
68
69
69
70
function MoneyTemporaryForRefactorRequestParticipantsSelector ( {
@@ -75,7 +76,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({
75
76
safeAreaPaddingBottomStyle,
76
77
iouType,
77
78
iouRequestType,
78
- isSearchingForReports ,
79
+ didScreenTransitionEnd ,
79
80
} ) {
80
81
const { translate} = useLocalize ( ) ;
81
82
const styles = useThemeStyles ( ) ;
@@ -95,6 +96,9 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({
95
96
*/
96
97
const [ sections , newChatOptions ] = useMemo ( ( ) => {
97
98
const newSections = [ ] ;
99
+ if ( ! didScreenTransitionEnd ) {
100
+ return [ newSections , { } ] ;
101
+ }
98
102
let indexOffset = 0 ;
99
103
100
104
const chatOptions = OptionsListUtils . getFilteredOptions (
@@ -169,7 +173,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({
169
173
}
170
174
171
175
return [ newSections , chatOptions ] ;
172
- } , [ reports , personalDetails , betas , searchTerm , participants , iouType , iouRequestType , maxParticipantsReached , translate ] ) ;
176
+ } , [ didScreenTransitionEnd , reports , personalDetails , betas , searchTerm , participants , iouType , iouRequestType , maxParticipantsReached , translate ] ) ;
173
177
174
178
/**
175
179
* Adds a single participant to the request
@@ -328,11 +332,13 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({
328
332
[ addParticipantToSelection , isAllowedToSplit , styles , translate ] ,
329
333
) ;
330
334
335
+ const isOptionsDataReady = useMemo ( ( ) => ReportUtils . isReportDataReady ( ) && OptionsListUtils . isPersonalDetailsReady ( personalDetails ) , [ personalDetails ] ) ;
336
+
331
337
return (
332
338
< View style = { [ styles . flex1 , styles . w100 , participants . length > 0 ? safeAreaPaddingBottomStyle : { } ] } >
333
339
< SelectionList
334
340
onConfirm = { handleConfirmSelection }
335
- sections = { sections }
341
+ sections = { didScreenTransitionEnd && isOptionsDataReady ? sections : CONST . EMPTY_ARRAY }
336
342
textInputValue = { searchTerm }
337
343
textInputLabel = { translate ( 'optionsSelector.nameEmailOrPhoneNumber' ) }
338
344
textInputHint = { offlineMessage }
@@ -341,7 +347,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({
341
347
onSelectRow = { addSingleParticipant }
342
348
footerContent = { footerContent }
343
349
headerMessage = { headerMessage }
344
- showLoadingPlaceholder = { isSearchingForReports }
350
+ showLoadingPlaceholder = { ! ( didScreenTransitionEnd && isOptionsDataReady ) }
345
351
rightHandSideComponent = { itemRightSideComponent }
346
352
/>
347
353
</ View >
@@ -359,8 +365,4 @@ export default withOnyx({
359
365
betas : {
360
366
key : ONYXKEYS . BETAS ,
361
367
} ,
362
- isSearchingForReports : {
363
- key : ONYXKEYS . IS_SEARCHING_FOR_REPORTS ,
364
- initWithStoredValues : false ,
365
- } ,
366
368
} ) ( MoneyTemporaryForRefactorRequestParticipantsSelector ) ;
0 commit comments