Skip to content

Commit 19d6d68

Browse files
committed
Conditionally update chatOptions on screen transition end
1 parent a5ed7d8 commit 19d6d68

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -230,37 +230,39 @@ function MoneyRequestParticipantsSelector({
230230
const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails);
231231

232232
useEffect(() => {
233-
const chatOptions = OptionsListUtils.getFilteredOptions(
234-
reports,
235-
personalDetails,
236-
betas,
237-
searchTerm,
238-
participants,
239-
CONST.EXPENSIFY_EMAILS,
240-
241-
// If we are using this component in the "Request money" flow then we pass the includeOwnedWorkspaceChats argument so that the current user
242-
// sees the option to request money from their admin on their own Workspace Chat.
243-
iouType === CONST.IOU.TYPE.REQUEST,
244-
245-
// We don't want to include any P2P options like personal details or reports that are not workspace chats for certain features.
246-
!isDistanceRequest,
247-
false,
248-
{},
249-
[],
250-
false,
251-
{},
252-
[],
253-
// We don't want the user to be able to invite individuals when they are in the "Distance request" flow for now.
254-
// This functionality is being built here: https://github.com/Expensify/App/issues/23291
255-
!isDistanceRequest,
256-
true,
257-
);
258-
setNewChatOptions({
259-
recentReports: chatOptions.recentReports,
260-
personalDetails: chatOptions.personalDetails,
261-
userToInvite: chatOptions.userToInvite,
262-
});
263-
}, [betas, reports, participants, personalDetails, translate, searchTerm, setNewChatOptions, iouType, isDistanceRequest]);
233+
if (didScreenTransitionEnd) {
234+
const chatOptions = OptionsListUtils.getFilteredOptions(
235+
reports,
236+
personalDetails,
237+
betas,
238+
searchTerm,
239+
participants,
240+
CONST.EXPENSIFY_EMAILS,
241+
242+
// If we are using this component in the "Request money" flow then we pass the includeOwnedWorkspaceChats argument so that the current user
243+
// sees the option to request money from their admin on their own Workspace Chat.
244+
iouType === CONST.IOU.TYPE.REQUEST,
245+
246+
// We don't want to include any P2P options like personal details or reports that are not workspace chats for certain features.
247+
!isDistanceRequest,
248+
false,
249+
{},
250+
[],
251+
false,
252+
{},
253+
[],
254+
// We don't want the user to be able to invite individuals when they are in the "Distance request" flow for now.
255+
// This functionality is being built here: https://github.com/Expensify/App/issues/23291
256+
!isDistanceRequest,
257+
true,
258+
);
259+
setNewChatOptions({
260+
recentReports: chatOptions.recentReports,
261+
personalDetails: chatOptions.personalDetails,
262+
userToInvite: chatOptions.userToInvite,
263+
});
264+
}
265+
}, [betas, reports, participants, personalDetails, translate, searchTerm, setNewChatOptions, iouType, isDistanceRequest, didScreenTransitionEnd]);
264266

265267
// When search term updates we will fetch any reports
266268
const setSearchTermAndSearchInServer = useCallback((text = '') => {

0 commit comments

Comments
 (0)