Skip to content

Commit ec1dd0c

Browse files
Merge pull request #58997 from rayane-d/Update-Global-Create-and-Workspace-chat-tooltips
Update Global Create and Workspace chat tooltips
2 parents a2fb98d + 853bc2d commit ec1dd0c

File tree

6 files changed

+49
-31
lines changed

6 files changed

+49
-31
lines changed

src/components/ProductTrainingContext/TOOLTIPS.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type ProductTrainingTooltipName = ValueOf<typeof CONST.PRODUCT_TRAINING_TOOLTIP_
1919

2020
type ShouldShowConditionProps = {
2121
shouldUseNarrowLayout: boolean;
22+
isUserPolicyEmployee: boolean;
2223
isUserPolicyAdmin: boolean;
2324
hasBeenAddedToNudgeMigration: boolean;
2425
};
@@ -60,11 +61,12 @@ const TOOLTIPS: Record<ProductTrainingTooltipName, TooltipData> = {
6061
{text: 'productTrainingTooltip.globalCreateTooltip.part1', isBold: true},
6162
{text: 'productTrainingTooltip.globalCreateTooltip.part2', isBold: false},
6263
{text: 'productTrainingTooltip.globalCreateTooltip.part3', isBold: false},
64+
{text: 'productTrainingTooltip.globalCreateTooltip.part4', isBold: false},
6365
],
6466
onHideTooltip: (isDismissedUsingCloseButton = false) => dismissProductTraining(GLOBAL_CREATE_TOOLTIP, isDismissedUsingCloseButton),
6567
name: GLOBAL_CREATE_TOOLTIP,
66-
priority: 1200,
67-
shouldShow: () => true,
68+
priority: 1950,
69+
shouldShow: ({isUserPolicyEmployee}) => isUserPolicyEmployee,
6870
},
6971
[BOTTOM_NAV_INBOX_TOOLTIP]: {
7072
content: [
@@ -80,14 +82,13 @@ const TOOLTIPS: Record<ProductTrainingTooltipName, TooltipData> = {
8082
},
8183
[LHN_WORKSPACE_CHAT_TOOLTIP]: {
8284
content: [
83-
{text: 'productTrainingTooltip.workspaceChatTooltip.part1', isBold: true},
84-
{text: 'productTrainingTooltip.workspaceChatTooltip.part2', isBold: false},
85-
{text: 'productTrainingTooltip.workspaceChatTooltip.part3', isBold: false},
85+
{text: 'productTrainingTooltip.workspaceChatTooltip.part1', isBold: false},
86+
{text: 'productTrainingTooltip.workspaceChatTooltip.part2', isBold: true},
8687
],
8788
onHideTooltip: (isDismissedUsingCloseButton = false) => dismissProductTraining(LHN_WORKSPACE_CHAT_TOOLTIP, isDismissedUsingCloseButton),
8889
name: LHN_WORKSPACE_CHAT_TOOLTIP,
89-
priority: 800,
90-
shouldShow: () => true,
90+
priority: 1800,
91+
shouldShow: ({isUserPolicyEmployee}) => isUserPolicyEmployee,
9192
},
9293
[EXPENSE_REPORTS_FILTER]: {
9394
content: [

src/components/ProductTrainingContext/index.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
1414
import {parseFSAttributes} from '@libs/Fullstory';
1515
import getPlatform from '@libs/getPlatform';
1616
import {hasCompletedGuidedSetupFlowSelector} from '@libs/onboardingSelectors';
17-
import {getActiveAdminWorkspaces} from '@libs/PolicyUtils';
17+
import {getActiveAdminWorkspaces, getActiveEmployeeWorkspaces} from '@libs/PolicyUtils';
1818
import isProductTrainingElementDismissed from '@libs/TooltipUtils';
1919
import variables from '@styles/variables';
2020
import CONST from '@src/CONST';
@@ -60,6 +60,13 @@ function ProductTrainingContextProvider({children}: ChildrenProps) {
6060
const [allPolicies, allPoliciesMetadata] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true});
6161
const [currentUserLogin, currentUserLoginMetadata] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email, canBeMissing: true});
6262

63+
const isUserPolicyEmployee = useMemo(() => {
64+
if (!allPolicies || !currentUserLogin || isLoadingOnyxValue(allPoliciesMetadata, currentUserLoginMetadata)) {
65+
return false;
66+
}
67+
return getActiveEmployeeWorkspaces(allPolicies, currentUserLogin).length > 0;
68+
}, [allPolicies, currentUserLogin, allPoliciesMetadata, currentUserLoginMetadata]);
69+
6370
const isUserPolicyAdmin = useMemo(() => {
6471
if (!allPolicies || !currentUserLogin || isLoadingOnyxValue(allPoliciesMetadata, currentUserLoginMetadata)) {
6572
return false;
@@ -68,6 +75,7 @@ function ProductTrainingContextProvider({children}: ChildrenProps) {
6875
}, [allPolicies, currentUserLogin, allPoliciesMetadata, currentUserLoginMetadata]);
6976

7077
const [dismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true});
78+
7179
const {shouldUseNarrowLayout} = useResponsiveLayout();
7280

7381
const [modal] = useOnyx(ONYXKEYS.MODAL, {canBeMissing: true});
@@ -141,6 +149,7 @@ function ProductTrainingContextProvider({children}: ChildrenProps) {
141149

142150
return tooltipConfig.shouldShow({
143151
shouldUseNarrowLayout,
152+
isUserPolicyEmployee,
144153
isUserPolicyAdmin,
145154
hasBeenAddedToNudgeMigration,
146155
});
@@ -153,6 +162,7 @@ function ProductTrainingContextProvider({children}: ChildrenProps) {
153162
shouldUseNarrowLayout,
154163
isModalVisible,
155164
isLoadingApp,
165+
isUserPolicyEmployee,
156166
isUserPolicyAdmin,
157167
],
158168
);

src/languages/en.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6218,14 +6218,14 @@ const translations = {
62186218
part4: 'chat about expenses.',
62196219
},
62206220
workspaceChatTooltip: {
6221-
part1: 'Submit expenses',
6222-
part2: ' and chat with',
6223-
part3: '\napprovers here!',
6221+
part1: 'Chat with ',
6222+
part2: 'approvers',
62246223
},
62256224
globalCreateTooltip: {
62266225
part1: 'Create expenses',
62276226
part2: ', start chatting,',
6228-
part3: '\nand more!',
6227+
part3: '\nand more.',
6228+
part4: ' Try it out!',
62296229
},
62306230
expenseReportsFilter: {
62316231
part1: 'Welcome! Find all of your',

src/languages/es.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -6743,14 +6743,14 @@ const translations = {
67436743
part4: 'chatea sobre los gastos.',
67446744
},
67456745
workspaceChatTooltip: {
6746-
part1: 'Envía gastos',
6747-
part2: ' y chatea con',
6748-
part3: '\naprobadores aquí!',
6746+
part1: 'Chatea con ',
6747+
part2: 'los aprobadores',
67496748
},
67506749
globalCreateTooltip: {
67516750
part1: 'Crea gastos',
6752-
part2: ', comienza a chatear,',
6753-
part3: '\ny mucho más!',
6751+
part2: ', empieza a chatear',
6752+
part3: '\ny más.',
6753+
part4: ' ¡Pruébalo!',
67546754
},
67556755
expenseReportsFilter: {
67566756
part1: '¡Bienvenido! Aquí encontrarás todos los',

src/libs/PolicyUtils.ts

+7
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,12 @@ function getActiveAdminWorkspaces(policies: OnyxCollection<Policy> | null, curre
718718
return activePolicies.filter((policy) => shouldShowPolicy(policy, isOfflineNetworkStore(), currentUserLogin) && isPolicyAdmin(policy, currentUserLogin));
719719
}
720720

721+
/** Return active policies where current user is an employee (of the role "user") */
722+
function getActiveEmployeeWorkspaces(policies: OnyxCollection<Policy> | null, currentUserLogin: string | undefined): Policy[] {
723+
const activePolicies = getActivePolicies(policies, currentUserLogin);
724+
return activePolicies.filter((policy) => shouldShowPolicy(policy, isOfflineNetworkStore(), currentUserLogin) && isPolicyUser(policy, currentUserLogin));
725+
}
726+
721727
/**
722728
*
723729
* Checks whether the current user has a policy with Xero accounting software integration
@@ -1559,6 +1565,7 @@ export {
15591565
getManagerAccountID,
15601566
isPrefferedExporter,
15611567
areAllGroupPoliciesExpenseChatDisabled,
1568+
getActiveEmployeeWorkspaces,
15621569
isUserInvitedToWorkspace,
15631570
};
15641571

tests/ui/components/ProductTrainingContextProvider.tsx

+14-14
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('ProductTrainingContextProvider', () => {
9393
Onyx.merge(ONYXKEYS.IS_LOADING_APP, true);
9494
await waitForBatchedUpdatesWithAct();
9595

96-
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
96+
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP;
9797
const {result} = renderHook(() => useProductTrainingContext(testTooltip), {wrapper});
9898

9999
// Then tooltip should not show
@@ -105,7 +105,7 @@ describe('ProductTrainingContextProvider', () => {
105105
Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {hasCompletedGuidedSetupFlow: false});
106106
await waitForBatchedUpdatesWithAct();
107107

108-
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
108+
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP;
109109
const {result} = renderHook(() => useProductTrainingContext(testTooltip), {wrapper});
110110

111111
// Then tooltip should not show
@@ -117,15 +117,15 @@ describe('ProductTrainingContextProvider', () => {
117117
Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {hasCompletedGuidedSetupFlow: true});
118118
await waitForBatchedUpdatesWithAct();
119119

120-
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
120+
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP;
121121
const {result} = renderHook(() => useProductTrainingContext(testTooltip), {wrapper});
122122

123123
// Then tooltip should show
124124
expect(result.current.shouldShowProductTrainingTooltip).toBe(true);
125125
});
126126

127127
it('should keep tooltip visible when another tooltip with shouldShow=false is unmounted', async () => {
128-
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
128+
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP;
129129
const ref = createRef<ProductTrainingRef>();
130130

131131
// When multiple tooltips with the same name but different shouldShow values are rendered
@@ -178,7 +178,7 @@ describe('ProductTrainingContextProvider', () => {
178178
await waitForBatchedUpdatesWithAct();
179179

180180
// Then tooltips should not show
181-
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
181+
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.BOTTOM_NAV_INBOX_TOOLTIP;
182182
const {result} = renderHook(() => useProductTrainingContext(testTooltip), {wrapper});
183183

184184
// Expect tooltip to be hidden
@@ -197,7 +197,7 @@ describe('ProductTrainingContextProvider', () => {
197197
});
198198
await waitForBatchedUpdatesWithAct();
199199

200-
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
200+
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.BOTTOM_NAV_INBOX_TOOLTIP;
201201
const {result} = renderHook(() => useProductTrainingContext(testTooltip), {wrapper});
202202

203203
// Then tooltip should show
@@ -210,7 +210,7 @@ describe('ProductTrainingContextProvider', () => {
210210
// When a tooltip has been dismissed
211211
const date = new Date();
212212
Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {hasCompletedGuidedSetupFlow: true});
213-
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
213+
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP;
214214
Onyx.merge(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {
215215
migratedUserWelcomeModal: {
216216
timestamp: DateUtils.getDBTime(date.valueOf()),
@@ -237,7 +237,7 @@ describe('ProductTrainingContextProvider', () => {
237237
},
238238
});
239239
await waitForBatchedUpdatesWithAct();
240-
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
240+
const testTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP;
241241
const {result, rerender} = renderHook(() => useProductTrainingContext(testTooltip), {wrapper});
242242
// When the user dismiss the tooltip
243243
result.current.hideProductTrainingTooltip();
@@ -295,8 +295,8 @@ describe('ProductTrainingContextProvider', () => {
295295
await waitForBatchedUpdatesWithAct();
296296

297297
// Then only highest priority tooltip should show
298-
const highPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
299-
const lowPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.LHN_WORKSPACE_CHAT_TOOLTIP;
298+
const highPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP_MANAGER;
299+
const lowPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP;
300300

301301
const {result} = renderHook(
302302
() => ({
@@ -315,8 +315,8 @@ describe('ProductTrainingContextProvider', () => {
315315
// When higher priority tooltip is dismissed
316316
Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {hasCompletedGuidedSetupFlow: true});
317317
const date = new Date();
318-
const highPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
319-
const lowPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.LHN_WORKSPACE_CHAT_TOOLTIP;
318+
const highPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP_MANAGER;
319+
const lowPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP;
320320

321321
Onyx.merge(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {
322322
migratedUserWelcomeModal: {
@@ -353,8 +353,8 @@ describe('ProductTrainingContextProvider', () => {
353353
});
354354
await waitForBatchedUpdatesWithAct();
355355

356-
const highPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP;
357-
const lowPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.LHN_WORKSPACE_CHAT_TOOLTIP;
356+
const highPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP_MANAGER;
357+
const lowPriorityTooltip = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP;
358358

359359
const {result} = renderHook(
360360
() => ({

0 commit comments

Comments
 (0)