@@ -12,12 +12,14 @@ import InviteMemberListItem from '@components/SelectionListWithSections/InviteMe
1212import type { Section } from '@components/SelectionListWithSections/types' ;
1313import withNavigationTransitionEnd from '@components/withNavigationTransitionEnd' ;
1414import type { WithNavigationTransitionEndProps } from '@components/withNavigationTransitionEnd' ;
15+ import useAncestors from '@hooks/useAncestors' ;
16+ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' ;
1517import useDebouncedState from '@hooks/useDebouncedState' ;
1618import useLocalize from '@hooks/useLocalize' ;
1719import useOnyx from '@hooks/useOnyx' ;
1820import useReportIsArchived from '@hooks/useReportIsArchived' ;
1921import useThemeStyles from '@hooks/useThemeStyles' ;
20- import { inviteToRoom , searchInServer } from '@libs/actions/Report' ;
22+ import { inviteToRoomAction , searchInServer } from '@libs/actions/Report' ;
2123import { clearUserSearchPhrase , updateUserSearchPhrase } from '@libs/actions/RoomMembersUserSearchPhrase' ;
2224import { READ_COMMANDS } from '@libs/API/types' ;
2325import { canUseTouchScreen } from '@libs/DeviceCapabilities' ;
@@ -55,13 +57,14 @@ function RoomInvitePage({
5557 } ,
5658} : RoomInvitePageProps ) {
5759 const styles = useThemeStyles ( ) ;
58- const { translate, formatPhoneNumber } = useLocalize ( ) ;
60+ const { translate} = useLocalize ( ) ;
5961 const [ userSearchPhrase ] = useOnyx ( ONYXKEYS . ROOM_MEMBERS_USER_SEARCH_PHRASE , { canBeMissing : true } ) ;
6062 const [ countryCode = CONST . DEFAULT_COUNTRY_CODE ] = useOnyx ( ONYXKEYS . COUNTRY_CODE , { canBeMissing : false } ) ;
6163 const [ searchTerm , debouncedSearchTerm , setSearchTerm ] = useDebouncedState ( userSearchPhrase ?? '' ) ;
6264 const [ selectedOptions , setSelectedOptions ] = useState < OptionData [ ] > ( [ ] ) ;
6365 const [ isSearchingForReports ] = useOnyx ( ONYXKEYS . IS_SEARCHING_FOR_REPORTS , { initWithStoredValues : false , canBeMissing : true } ) ;
6466 const isReportArchived = useReportIsArchived ( report . reportID ) ;
67+ const currentUserPersonalDetails = useCurrentUserPersonalDetails ( ) ;
6568 const [ nvpDismissedProductTraining ] = useOnyx ( ONYXKEYS . NVP_DISMISSED_PRODUCT_TRAINING , { canBeMissing : true } ) ;
6669
6770 const { options, areOptionsInitialized} = useOptionsList ( ) ;
@@ -192,6 +195,9 @@ function RoomInvitePage({
192195 return reportID && ( ! isPolicyEmployee || isReportArchived ? ROUTES . REPORT_WITH_ID_DETAILS . getRoute ( reportID , backTo ) : ROUTES . ROOM_MEMBERS . getRoute ( reportID , backTo ) ) ;
193196 } , [ isPolicyEmployee , reportID , backTo , isReportArchived ] ) ;
194197 const reportName = useMemo ( ( ) => getReportName ( report ) , [ report ] ) ;
198+
199+ const ancestors = useAncestors ( report ) ;
200+
195201 const inviteUsers = useCallback ( ( ) => {
196202 HttpUtils . cancelPendingRequests ( READ_COMMANDS . SEARCH_FOR_REPORTS ) ;
197203
@@ -208,11 +214,15 @@ function RoomInvitePage({
208214 invitedEmailsToAccountIDs [ login ] = Number ( accountID ) ;
209215 }
210216 if ( reportID ) {
211- inviteToRoom ( reportID , invitedEmailsToAccountIDs , formatPhoneNumber ) ;
217+ inviteToRoomAction ( reportID , ancestors , invitedEmailsToAccountIDs , currentUserPersonalDetails . timezone ?? CONST . DEFAULT_TIME_ZONE ) ;
218+ clearUserSearchPhrase ( ) ;
219+ if ( backTo ) {
220+ Navigation . goBack ( backTo ) ;
221+ } else {
222+ Navigation . goBack ( ROUTES . REPORT_WITH_ID . getRoute ( reportID ) ) ;
223+ }
212224 }
213- clearUserSearchPhrase ( ) ;
214- Navigation . goBack ( backRoute ) ;
215- } , [ selectedOptions , backRoute , reportID , validate , formatPhoneNumber ] ) ;
225+ } , [ validate , selectedOptions , ancestors , reportID , currentUserPersonalDetails . timezone , backTo ] ) ;
216226
217227 const goBack = useCallback ( ( ) => {
218228 Navigation . goBack ( backRoute ) ;
0 commit comments