diff --git a/src/components/OptionListContextProvider.tsx b/src/components/OptionListContextProvider.tsx index 1603de9e3d10..93b302ef19fd 100644 --- a/src/components/OptionListContextProvider.tsx +++ b/src/components/OptionListContextProvider.tsx @@ -151,10 +151,6 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { }, [personalDetails, reports]); const initializeOptions = useCallback(() => { - if (areOptionsInitialized.current) { - return; - } - loadOptions(); areOptionsInitialized.current = true; }, [loadOptions]); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index edfe8546cf13..ed43cf590639 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4599,7 +4599,8 @@ function getChatRoomSubtitle(report: OnyxEntry, config: GetChatRoomSubti return report?.reportName?.substring(1) ?? ''; } if ((isPolicyExpenseChat(report) && !!report?.isOwnPolicyExpenseChat) || isExpenseReport(report)) { - const submitToAccountID = getSubmitToAccountID(getPolicy(report?.policyID), report); + const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]; + const submitToAccountID = getSubmitToAccountID(policy, report); const submitsToAccountDetails = allPersonalDetails?.[submitToAccountID]; const subtitle = submitsToAccountDetails?.displayName ?? submitsToAccountDetails?.login; diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index 0c333ed71cba..9091c3ba0ded 100644 --- a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx +++ b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx @@ -78,7 +78,7 @@ function MoneyRequestParticipantsSelector({participants = CONST.EMPTY_ARRAY, onF const policy = usePolicy(activePolicyID); const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false}); const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email}); - const {options, areOptionsInitialized} = useOptionsList({ + const {options, areOptionsInitialized, initializeOptions} = useOptionsList({ shouldInitialize: didScreenTransitionEnd, }); const cleanSearchTerm = useMemo(() => debouncedSearchTerm.trim().toLowerCase(), [debouncedSearchTerm]); @@ -92,6 +92,12 @@ function MoneyRequestParticipantsSelector({participants = CONST.EMPTY_ARRAY, onF searchInServer(debouncedSearchTerm.trim()); }, [debouncedSearchTerm]); + useEffect(() => { + // This is necessary to ensure the options list is always up to date + // e.g. if the approver was changed in the policy, we need to update the options list + initializeOptions(); + }, [initializeOptions]); + const defaultOptions = useMemo(() => { if (!areOptionsInitialized || !didScreenTransitionEnd) { return {