@@ -2,12 +2,13 @@ import {useFocusEffect} from '@react-navigation/native';
22import React , { useCallback , useContext , useEffect , useRef , useState } from 'react' ;
33import type { ImageStyle , StyleProp } from 'react-native' ;
44import { Image , StyleSheet , View } from 'react-native' ;
5+ import type { ValueOf } from 'type-fest' ;
56import Avatar from '@components/Avatar' ;
67import AvatarWithImagePicker from '@components/AvatarWithImagePicker' ;
78import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu' ;
89import type { DropdownOption } from '@components/ButtonWithDropdownMenu/types' ;
910import ConfirmModal from '@components/ConfirmModal' ;
10- import { FallbackWorkspaceAvatar , ImageCropSquareMask , QrCode , Trashcan , UserPlus } from '@components/Icon/Expensicons' ;
11+ import { FallbackWorkspaceAvatar , ImageCropSquareMask , QrCode , Transfer , Trashcan , UserPlus } from '@components/Icon/Expensicons' ;
1112import { Building } from '@components/Icon/Illustrations' ;
1213import { LockedAccountContext } from '@components/LockedAccountModalProvider' ;
1314import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription' ;
@@ -21,7 +22,7 @@ import usePayAndDowngrade from '@hooks/usePayAndDowngrade';
2122import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
2223import useThemeIllustrations from '@hooks/useThemeIllustrations' ;
2324import useThemeStyles from '@hooks/useThemeStyles' ;
24- import { clearInviteDraft } from '@libs/actions/Policy/Member' ;
25+ import { clearInviteDraft , clearWorkspaceOwnerChangeFlow , requestWorkspaceOwnerChange } from '@libs/actions/Policy/Member' ;
2526import {
2627 calculateBillNewDot ,
2728 clearAvatarErrors ,
@@ -39,6 +40,7 @@ import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavig
3940import type { WorkspaceSplitNavigatorParamList } from '@libs/Navigation/types' ;
4041import { getUserFriendlyWorkspaceType , goBackFromInvalidPolicy , isPolicyAdmin as isPolicyAdminPolicyUtils , isPolicyOwner } from '@libs/PolicyUtils' ;
4142import { getDefaultWorkspaceAvatar } from '@libs/ReportUtils' ;
43+ import shouldRenderTransferOwnerButton from '@libs/shouldRenderTransferOwnerButton' ;
4244import StringUtils from '@libs/StringUtils' ;
4345import { shouldCalculateBillNewDot } from '@libs/SubscriptionUtils' ;
4446import { getFullSizeAvatar } from '@libs/UserUtils' ;
@@ -70,6 +72,7 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
7072
7173 // When we create a new workspace, the policy prop will be empty on the first render. Therefore, we have to use policyDraft until policy has been set in Onyx.
7274 const policy = policyDraft ?. id ? policyDraft : policyProp ;
75+
7376 const isPolicyAdmin = isPolicyAdminPolicyUtils ( policy ) ;
7477 const outputCurrency = policy ?. outputCurrency ?? '' ;
7578 const currencySymbol = currencyList ?. [ outputCurrency ] ?. symbol ?? '' ;
@@ -221,6 +224,15 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
221224 Navigation . popToSidebar ( ) ;
222225 } ;
223226
227+ const startChangeOwnershipFlow = useCallback ( ( ) => {
228+ if ( ! policy ?. id || ! policy ?. ownerAccountID ) {
229+ return ;
230+ }
231+ clearWorkspaceOwnerChangeFlow ( policy . id ) ;
232+ requestWorkspaceOwnerChange ( policy . id ) ;
233+ Navigation . navigate ( ROUTES . WORKSPACE_OWNER_CHANGE_CHECK . getRoute ( policy . id , policy . ownerAccountID , 'amountOwed' as ValueOf < typeof CONST . POLICY . OWNERSHIP_ERRORS > ) ) ;
234+ } , [ policy ] ) ;
235+
224236 const getHeaderButtons = ( ) => {
225237 if ( readOnly ) {
226238 return null ;
@@ -258,6 +270,14 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
258270 shouldCloseModalOnSelect : ! shouldCalculateBillNewDot ( ) ,
259271 } ) ;
260272 }
273+ if ( isPolicyAdmin && ! isOwner && shouldRenderTransferOwnerButton ( ) ) {
274+ secondaryActions . push ( {
275+ value : 'transferOwner' ,
276+ text : translate ( 'workspace.people.transferOwner' ) ,
277+ icon : Transfer ,
278+ onSelected : startChangeOwnershipFlow ,
279+ } ) ;
280+ }
261281 return (
262282 < View style = { [ ! shouldUseNarrowLayout && styles . flexRow , ! shouldUseNarrowLayout && styles . gap2 ] } >
263283 < ButtonWithDropdownMenu
0 commit comments