Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6894,6 +6894,7 @@ const CONST = {
RHP_HOME_PAGE: 'rhpHomePage',
TRACK_EXPENSES_WITH_CONCIERGE: 'trackExpensesWithConcierge',
CONTROL: 'control',
INB_ADMINS_WEL: 'inbAdminsWel',
},
ONBOARDING_JOINABLE_WORKSPACES_LIMIT: 5,
ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE: 'What would you like to do with this expense?',
Expand Down
13 changes: 7 additions & 6 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11701,8 +11701,7 @@ function prepareOnboardingOnyxData({
let addExpenseApprovalsTaskReportID;
let setupTagsTaskReportID;
let setupCategoriesAndTagsTaskReportID;
// If shouldUseFollowupsInsteadOfTasks we do not want to generate tasks in favour of followups.
const tasks = shouldUseFollowupsInsteadOfTasks ? [] : onboardingMessage.tasks;
const tasks = onboardingMessage.tasks;
const tasksData = tasks
.filter((task) => {
if (([CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES, CONST.ONBOARDING_TASK_TYPE.SETUP_TAGS] as string[]).includes(task.type) && userReportedIntegration) {
Expand Down Expand Up @@ -11805,7 +11804,7 @@ function prepareOnboardingOnyxData({
description: taskDescription ?? '',
}));

const hasOutstandingChildTask = tasksData.some((task) => !task.completedTaskReportAction);
const hasOutstandingChildTask = !shouldUseFollowupsInsteadOfTasks && tasksData.some((task) => !task.completedTaskReportAction);

const tasksForOptimisticData = tasksData.reduce<
Array<
Expand Down Expand Up @@ -11958,7 +11957,9 @@ function prepareOnboardingOnyxData({
return acc;
}, []);

const optimisticData: Array<TupleToUnion<typeof tasksForOptimisticData> | OnyxUpdate<typeof ONYXKEYS.COLLECTION.POLICY>> = [...tasksForOptimisticData];
const optimisticData: Array<TupleToUnion<typeof tasksForOptimisticData> | OnyxUpdate<typeof ONYXKEYS.COLLECTION.POLICY>> = shouldUseFollowupsInsteadOfTasks
? []
: [...tasksForOptimisticData];
const skipSignOff = shouldUseFollowupsInsteadOfTasks || engagementChoice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND;
const lastVisibleActionCreated = skipSignOff ? textCommentAction.created : welcomeSignOffCommentAction.created;
optimisticData.push(
Expand Down Expand Up @@ -12003,7 +12004,7 @@ function prepareOnboardingOnyxData({

const successData: Array<
TupleToUnion<typeof tasksForSuccessData> | OnyxUpdate<typeof ONYXKEYS.COLLECTION.POLICY | typeof ONYXKEYS.PERSONAL_DETAILS_LIST | typeof ONYXKEYS.NVP_ONBOARDING>
> = [...tasksForSuccessData];
> = shouldUseFollowupsInsteadOfTasks ? [] : [...tasksForSuccessData];

if (message) {
successData.push({
Expand Down Expand Up @@ -12037,7 +12038,7 @@ function prepareOnboardingOnyxData({
const failureData: Array<
| TupleToUnion<typeof tasksForFailureData>
| OnyxUpdate<typeof ONYXKEYS.NVP_INTRO_SELECTED | typeof ONYXKEYS.NVP_ONBOARDING | typeof ONYXKEYS.COLLECTION.POLICY | typeof ONYXKEYS.PERSONAL_DETAILS_LIST>
> = [...tasksForFailureData];
> = shouldUseFollowupsInsteadOfTasks ? [] : [...tasksForFailureData];
failureData.push(
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down
3 changes: 2 additions & 1 deletion src/types/onyx/OnboardingRHPVariant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* @description 'rhpAdminsRoom' - Admin of workspace with the admins room
* @description 'rhpHomePage' - Navigate to Home page with Concierge Anywhere accessible in #admins room
* @description 'trackExpensesWithConcierge' - Track workspace admins land on Home page with Concierge side panel (desktop) or Concierge chat (mobile)
* @description 'inbAdminsWel' - Bespoke welcome message delivered in #admins room instead of onboarding tasks
*/
type OnboardingRHPVariant = 'rhpConciergeDm' | 'rhpAdminsRoom' | 'rhpHomePage' | 'trackExpensesWithConcierge' | 'control';
type OnboardingRHPVariant = 'rhpConciergeDm' | 'rhpAdminsRoom' | 'rhpHomePage' | 'trackExpensesWithConcierge' | 'control' | 'inbAdminsWel';

export default OnboardingRHPVariant;
40 changes: 22 additions & 18 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ describe('ReportUtils', () => {
);
});

it('should not add anything to guidedSetupData when posting into the admin room for MANAGE_TEAM', async () => {
it('should send tasks to server but not add them to optimisticData for MANAGE_TEAM', async () => {
const adminsChatReportID = '1';
// Not having `+` in the email allows for `isPostingTasksInAdminsRoom` flow
await Onyx.merge(ONYXKEYS.SESSION, {email: 'test@example.com'});
Expand All @@ -649,8 +649,9 @@ describe('ReportUtils', () => {
adminsChatReportID,
companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO,
});
expect(result?.guidedSetupData).toHaveLength(0);
// Server is sole source of truth for the bespoke welcome — no optimistic action added here.
// Tasks are sent to server via guidedSetupData; not added optimistically to avoid flash.
expect(result?.guidedSetupData).toHaveLength(1);
// No optimistic task report actions — server creates tasks from guidedSetupData.
const reportActionsEntries = result?.optimisticData.filter((i) => i.key === `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${adminsChatReportID}`);
expect(reportActionsEntries).toHaveLength(0);
expect(result?.optimisticConciergeReportActionID).toBeDefined();
Expand All @@ -671,7 +672,7 @@ describe('ReportUtils', () => {
adminsChatReportID,
companySize: CONST.ONBOARDING_COMPANY_SIZE.SMALL,
});
expect(result?.guidedSetupData).toHaveLength(0);
expect(result?.guidedSetupData).toHaveLength(1);
expect(result?.optimisticConciergeReportActionID).toBeDefined();
});

Expand All @@ -690,7 +691,7 @@ describe('ReportUtils', () => {
adminsChatReportID,
companySize: CONST.ONBOARDING_COMPANY_SIZE.LARGE,
});
expect(result?.guidedSetupData).toHaveLength(0);
expect(result?.guidedSetupData).toHaveLength(1);
expect(result?.optimisticConciergeReportActionID).toBeDefined();
});

Expand All @@ -709,7 +710,7 @@ describe('ReportUtils', () => {
adminsChatReportID,
companySize: CONST.ONBOARDING_COMPANY_SIZE.MEDIUM_SMALL,
});
expect(result?.guidedSetupData).toHaveLength(0);
expect(result?.guidedSetupData).toHaveLength(1);
expect(result?.optimisticConciergeReportActionID).toBeDefined();
});

Expand All @@ -728,7 +729,7 @@ describe('ReportUtils', () => {
adminsChatReportID,
companySize: CONST.ONBOARDING_COMPANY_SIZE.MEDIUM,
});
expect(result?.guidedSetupData).toHaveLength(0);
expect(result?.guidedSetupData).toHaveLength(1);
expect(result?.optimisticConciergeReportActionID).toBeDefined();
});

Expand All @@ -752,7 +753,7 @@ describe('ReportUtils', () => {
expect(result?.optimisticConciergeReportActionID).toBeDefined();
});

it('should use followups for MANAGE_TEAM unconditionally', async () => {
it('should send tasks to server for MANAGE_TEAM but not add them to optimisticData', async () => {
const adminsChatReportID = '1';
await waitForBatchedUpdates();

Expand All @@ -766,15 +767,14 @@ describe('ReportUtils', () => {
adminsChatReportID,
companySize: CONST.ONBOARDING_COMPANY_SIZE.SMALL,
});
// Every MANAGE_TEAM signup uses the bespoke followups path — tasks are never generated
expect(result?.guidedSetupData.filter((data) => data.type === 'task')).toHaveLength(0);
// MANAGE_TEAM: tasks sent to server via guidedSetupData but excluded from optimisticData to prevent flash.
expect(result?.guidedSetupData.filter((data) => data.type === 'task')).toHaveLength(1);
expect(result?.optimisticConciergeReportActionID).toBeDefined();
});

it('should generate followups (not tasks) for `+` email users in the MANAGE_TEAM + MICRO Phase 1 cohort', async () => {
// Phase 1 cohort opens the followups path to all MANAGE_TEAM 1-10 users — including `+` aliases
// and phone-primary sign-ups. The `+` exclusion in `isPostingTasksInAdminsRoom` was scoped to
// the trial-banner placement (PR #53895, #71355) and must not block followups for cohort users.
it('should send tasks to server for MANAGE_TEAM + MICRO users including `+` email aliases', async () => {
// Tasks are sent server-side for all MANAGE_TEAM users regardless of email format.
// The `+` exclusion in `isPostingTasksInAdminsRoom` scopes trial-banner placement only.
const adminsChatReportID = '1';
await waitForBatchedUpdates();

Expand All @@ -788,14 +788,14 @@ describe('ReportUtils', () => {
adminsChatReportID,
companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO,
});
// Followups path active: no tasks generated; server posts bespoke welcome (no optimistic action).
expect(result?.guidedSetupData.filter((data) => data.type === 'task')).toHaveLength(0);
// Tasks sent to server via guidedSetupData; no optimistic task actions added.
expect(result?.guidedSetupData.filter((data) => data.type === 'task')).toHaveLength(1);
expect(result?.optimisticConciergeReportActionID).toBeDefined();
const adminsRoomActions = result?.optimisticData.filter((i) => i.key === `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${adminsChatReportID}`);
expect(adminsRoomActions).toHaveLength(0);
});

it('should not create tasks if the task feature is not in the selected interested features', () => {
it('should send tasks to server for MANAGE_TEAM without adding them to optimisticData', () => {
const result = prepareOnboardingOnyxData({
introSelected: undefined,
engagementChoice: CONST.ONBOARDING_CHOICES.MANAGE_TEAM,
Expand All @@ -807,7 +807,7 @@ describe('ReportUtils', () => {
companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO,
});

expect(result?.guidedSetupData.filter((data) => data.type === 'task')).toHaveLength(0);
expect(result?.guidedSetupData.filter((data) => data.type === 'task')).toHaveLength(1);
});

it('includes avatar and accountID in optimistic Setup Specialist personal detail', async () => {
Expand Down Expand Up @@ -1015,6 +1015,10 @@ describe('ReportUtils', () => {
expect(viewTourTask).toBeDefined();
expect(viewTourTask?.completedTaskReportActionID).toBeDefined();
});

it('should recognize inbAdminsWel as a valid onboarding RHP variant', () => {
expect(CONST.ONBOARDING_RHP_VARIANT.INB_ADMINS_WEL).toBe('inbAdminsWel');
});
});

describe('getIconsForParticipants', () => {
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/navigateAfterOnboardingTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,10 @@ describe('navigateAfterOnboarding', () => {
navigateAfterOnboarding(true, true, '', new Set(), ONBOARDING_POLICY_ID, ONBOARDING_ADMINS_CHAT_REPORT_ID, (testSession?.email ?? '').includes('+'));
expect(navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(REPORT_ID));
});

it('should navigate to the admin room when the inbAdminsWel variant is assigned', () => {
const navigate = jest.spyOn(Navigation, 'navigate');
navigateAfterOnboarding(false, true, '', new Set(), undefined, ONBOARDING_ADMINS_CHAT_REPORT_ID, false, CONST.ONBOARDING_RHP_VARIANT.INB_ADMINS_WEL);
expect(navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(ONBOARDING_ADMINS_CHAT_REPORT_ID));
});
});
Loading