Skip to content

Commit 3900414

Browse files
authored
Merge pull request Expensify#86289 from Expensify/marcochavezf/610149-rhp-home-page-variant
[Payment due @thesahindia] Add rhpHomePage variant to onboarding A/B/C/D test
2 parents 33388d4 + c214b6e commit 3900414

6 files changed

Lines changed: 39 additions & 14 deletions

File tree

src/CONST/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6533,6 +6533,7 @@ const CONST = {
65336533
ONBOARDING_RHP_VARIANT: {
65346534
RHP_CONCIERGE_DM: 'rhpConciergeDm',
65356535
RHP_ADMINS_ROOM: 'rhpAdminsRoom',
6536+
RHP_HOME_PAGE: 'rhpHomePage',
65366537
CONTROL: 'control',
65376538
},
65386539
ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE: 'What would you like to do with this expense?',

src/components/SidePanel/RHPVariantTest/index.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,25 @@ const shouldOpenRHPVariant: ShouldOpenRHPVariant = () => {
3434
const isMicroCompany = onboardingCompanySize === CONST.ONBOARDING_COMPANY_SIZE.MICRO;
3535
const isRHPConciergeDM = onboardingRHPVariant === CONST.ONBOARDING_RHP_VARIANT.RHP_CONCIERGE_DM;
3636
const isRHPAdminsRoom = onboardingRHPVariant === CONST.ONBOARDING_RHP_VARIANT.RHP_ADMINS_ROOM;
37+
const isRHPHomePage = onboardingRHPVariant === CONST.ONBOARDING_RHP_VARIANT.RHP_HOME_PAGE;
3738

38-
return isMicroCompany && (isRHPConciergeDM || isRHPAdminsRoom);
39+
return isMicroCompany && (isRHPConciergeDM || isRHPAdminsRoom || isRHPHomePage);
3940
};
4041

4142
/**
42-
* Handles navigation for RHP experiment:
43-
* - Control: navigate to the last accessed report on small screens, do not open side panel
44-
* - RHP Concierge DM: navigate to the workspace overview and open the side panel with the Concierge DM
45-
* - RHP Admins Room: navigate to the workspace overview and open the side panel with the Admins Room
43+
* Handles navigation for RHP experiment variants (B/C/D):
44+
* Variants B and C navigate to the workspace overview, Variant D navigates to home.
45+
* All variants open the side panel without overlay.
46+
* The control variant is handled separately in navigateAfterOnboarding.
4647
*/
4748
const handleRHPVariantNavigation: HandleRHPVariantNavigation = (onboardingPolicyID) => {
48-
Navigation.navigate(ROUTES.WORKSPACE_OVERVIEW.getRoute(onboardingPolicyID));
49+
const isRHPHomePage = onboardingRHPVariant === CONST.ONBOARDING_RHP_VARIANT.RHP_HOME_PAGE;
50+
51+
if (isRHPHomePage) {
52+
Navigation.navigate(ROUTES.HOME);
53+
} else {
54+
Navigation.navigate(ROUTES.WORKSPACE_OVERVIEW.getRoute(onboardingPolicyID));
55+
}
4956
SidePanelActions.openSidePanel(true);
5057
};
5158

src/components/SidePanel/SidePanelContextProvider.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type SidePanelStateContextProps = {
2828
sidePanelOffset: RefObject<Animated.Value>;
2929
sidePanelTranslateX: RefObject<Animated.Value>;
3030
sidePanelNVP?: SidePanel;
31-
reportID?: string;
3231
sessionStartTime: string | null;
3332
};
3433

@@ -49,6 +48,8 @@ const SidePanelStateContext = createContext<SidePanelStateContextProps>({
4948
sessionStartTime: null,
5049
});
5150

51+
const SidePanelReportIDContext = createContext<string | undefined>(undefined);
52+
5253
const SidePanelActionsContext = createContext<SidePanelActionsContextProps>({
5354
openSidePanel: () => {},
5455
closeSidePanel: () => {},
@@ -80,11 +81,12 @@ function SidePanelContextProvider({children}: PropsWithChildren) {
8081
});
8182

8283
const isRHPAdminsRoom = onboardingRHPVariant === CONST.ONBOARDING_RHP_VARIANT.RHP_ADMINS_ROOM;
84+
const isRHPHomePage = onboardingRHPVariant === CONST.ONBOARDING_RHP_VARIANT.RHP_HOME_PAGE;
8385
const isUserAdmin = isPolicyAdmin(activePolicy, sessionEmail);
8486
const isPolicyActive = shouldShowPolicy(activePolicy, false, sessionEmail ?? '');
8587
const adminsChatReportID = activePolicy?.chatReportIDAdmins?.toString();
8688

87-
const reportID = isRHPAdminsRoom && isUserAdmin && isPolicyActive && adminsChatReportID ? adminsChatReportID : conciergeReportID;
89+
const reportID = (isRHPAdminsRoom || isRHPHomePage) && isUserAdmin && isPolicyActive && adminsChatReportID ? adminsChatReportID : conciergeReportID;
8890

8991
const [sessionStartTime, setSessionStartTime] = useState<string | null>(null);
9092
const [prevShouldHideSidePanel, setPrevShouldHideSidePanel] = useState(shouldHideSidePanel);
@@ -145,7 +147,6 @@ function SidePanelContextProvider({children}: PropsWithChildren) {
145147
sidePanelOffset,
146148
sidePanelTranslateX,
147149
sidePanelNVP,
148-
reportID,
149150
sessionStartTime,
150151
};
151152

@@ -158,10 +159,12 @@ function SidePanelContextProvider({children}: PropsWithChildren) {
158159

159160
return (
160161
<SidePanelStateContext.Provider value={stateValue}>
161-
<SidePanelActionsContext.Provider value={actionsValue}>{children}</SidePanelActionsContext.Provider>
162+
<SidePanelReportIDContext.Provider value={reportID}>
163+
<SidePanelActionsContext.Provider value={actionsValue}>{children}</SidePanelActionsContext.Provider>
164+
</SidePanelReportIDContext.Provider>
162165
</SidePanelStateContext.Provider>
163166
);
164167
}
165168

166169
export default SidePanelContextProvider;
167-
export {SidePanelStateContext, SidePanelActionsContext};
170+
export {SidePanelStateContext, SidePanelReportIDContext, SidePanelActionsContext};

src/components/SidePanel/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import React from 'react';
22
import useSidePanelActions from '@hooks/useSidePanelActions';
3+
import useSidePanelReportID from '@hooks/useSidePanelReportID';
34
import useSidePanelState from '@hooks/useSidePanelState';
45
import type {ExtraContentProps} from '@libs/Navigation/PlatformStackNavigation/types';
56
import SidePanelModal from './SidePanelModal';
67
import SidePanelReport from './SidePanelReport';
78
import useSyncSidePanelWithHistory from './useSyncSidePanelWithHistory';
89

910
function SidePanel({navigation}: Pick<ExtraContentProps, 'navigation'>) {
10-
const {sidePanelNVP, isSidePanelTransitionEnded, shouldHideSidePanel, sidePanelTranslateX, shouldHideSidePanelBackdrop, reportID} = useSidePanelState();
11+
const {sidePanelNVP, isSidePanelTransitionEnded, shouldHideSidePanel, sidePanelTranslateX, shouldHideSidePanelBackdrop} = useSidePanelState();
12+
const reportID = useSidePanelReportID();
1113
const {closeSidePanel} = useSidePanelActions();
1214

1315
// Hide side panel once animation ends

src/hooks/useSidePanelReportID.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {useContext} from 'react';
2+
import {SidePanelReportIDContext} from '@components/SidePanel/SidePanelContextProvider';
3+
4+
/**
5+
* Hook to get the reportID used by the Side Panel.
6+
* Separated from useSidePanelState to avoid re-rendering components
7+
* that don't need reportID when it changes.
8+
*/
9+
const useSidePanelReportID = () => useContext(SidePanelReportIDContext);
10+
11+
export default useSidePanelReportID;
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/**
2-
* The variant of the onboarding RHP for A/B/C testing
2+
* The variant of the onboarding RHP for A/B/C/D testing
33
* @description 'control' - The variant with the Concierge DM
44
* @description 'rhpConciergeDm' - Admin of workspace with Concierge DM
55
* @description 'rhpAdminsRoom' - Admin of workspace with the admins room
6+
* @description 'rhpHomePage' - Navigate to Home page with Concierge Anywhere accessible in #admins room
67
*/
7-
type OnboardingRHPVariant = 'rhpConciergeDm' | 'rhpAdminsRoom' | 'control';
8+
type OnboardingRHPVariant = 'rhpConciergeDm' | 'rhpAdminsRoom' | 'rhpHomePage' | 'control';
89

910
export default OnboardingRHPVariant;

0 commit comments

Comments
 (0)