From d95b51f05716d81f024fcea7511182da2d61ded8 Mon Sep 17 00:00:00 2001 From: c3024 Date: Fri, 8 Nov 2024 18:08:04 +0530 Subject: [PATCH 01/25] wip-move-tasks-to-admin-2 --- src/CONST.ts | 2 ++ src/libs/actions/Report.ts | 10 +++++++--- src/pages/home/ReportScreen.tsx | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index d5dcb0e33f63..924cf1ba7274 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1619,6 +1619,7 @@ const CONST = { NOTIFICATIONS: 'notifications@expensify.com', PAYROLL: 'payroll@expensify.com', QA: 'qa@expensify.com', + QA_GUIDES: 'qa.guide@team.expensify.com', QA_TRAVIS: 'qa+travisreceipts@expensify.com', RECEIPTS: 'receipts@expensify.com', STUDENT_AMBASSADOR: 'studentambassadors@expensify.com', @@ -2079,6 +2080,7 @@ const CONST = { NOTIFICATIONS: Number(Config?.EXPENSIFY_ACCOUNT_ID_NOTIFICATIONS ?? 11665625), PAYROLL: Number(Config?.EXPENSIFY_ACCOUNT_ID_PAYROLL ?? 9679724), QA: Number(Config?.EXPENSIFY_ACCOUNT_ID_QA ?? 3126513), + QA_GUIDE: Number(Config?.EXPENSIFY_ACCOUNT_ID_QA_GUIDE ?? 14365522), QA_TRAVIS: Number(Config?.EXPENSIFY_ACCOUNT_ID_QA_TRAVIS ?? 8595733), RECEIPTS: Number(Config?.EXPENSIFY_ACCOUNT_ID_RECEIPTS ?? -1), REWARDS: Number(Config?.EXPENSIFY_ACCOUNT_ID_REWARDS ?? 11023767), // rewards@expensify.com diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index e6a10d01b798..70b275102704 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3439,8 +3439,11 @@ function completeOnboarding( } const integrationName = userReportedIntegration ? CONST.ONBOARDING_ACCOUNTING_MAPPING[userReportedIntegration] : ''; - const actorAccountID = CONST.ACCOUNT_ID.CONCIERGE; - const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); + const actorAccountID = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.ACCOUNT_ID.QA_GUIDE : CONST.ACCOUNT_ID.CONCIERGE; + // const actorAccountID = CONST.ACCOUNT_ID.CONCIERGE; + const adminsChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`]; + const targetChatReport = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); + // const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; // Introductory message @@ -3507,7 +3510,8 @@ function completeOnboarding( targetChatPolicyID, CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, ); - const taskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(CONST.EMAIL.CONCIERGE); + const emailCreatingAction = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.EMAIL.QA_GUIDES : CONST.EMAIL.CONCIERGE; + const taskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(emailCreatingAction); const taskReportAction = ReportUtils.buildOptimisticTaskCommentReportAction( currentTask.reportID, taskTitle, diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 4c3ed5c705a5..2b0201b19148 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -55,6 +55,7 @@ import ReportActionsView from './report/ReportActionsView'; import ReportFooter from './report/ReportFooter'; import type {ActionListContextType, ReactionListRef, ScrollPosition} from './ReportScreenContext'; import {ActionListContext, ReactionListContext} from './ReportScreenContext'; +import { usePersonalDetails } from '@components/OnyxProvider'; type ReportScreenNavigationProps = StackScreenProps; @@ -97,6 +98,8 @@ function getParentReportAction(parentReportActions: OnyxEntry Date: Fri, 8 Nov 2024 18:47:55 +0530 Subject: [PATCH 02/25] fix qa guide personal detail --- src/libs/actions/Report.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 70b275102704..b1d2a9afbedb 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3445,7 +3445,16 @@ function completeOnboarding( const targetChatReport = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); // const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; - + console.log("actorAccountID ", actorAccountID, "currentUserAccountID ", currentUserAccountID, "targetChatReport ", targetChatReport, "targetChatReportID ", targetChatReportID, "targetChatPolicyID ", targetChatPolicyID); + if (engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) { + const optimisticPersonalDetailForQAGuide = { + accountID: actorAccountID, + avatar: allPersonalDetails?.[actorAccountID]?.avatar, + displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDES, + login: CONST.EMAIL.QA_GUIDES, + }; + Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); + }; // Introductory message const introductionComment = ReportUtils.buildOptimisticAddCommentReportAction(CONST.ONBOARDING_INTRODUCTION, undefined, actorAccountID); const introductionCommentAction: OptimisticAddCommentReportAction = introductionComment.reportAction; From d27f2733bd8e2a980b58e56595e3b1eefb2f4a93 Mon Sep 17 00:00:00 2001 From: c3024 Date: Mon, 11 Nov 2024 20:43:06 +0530 Subject: [PATCH 03/25] troubleshoot LHN alternate text --- ios/NewExpensify.xcodeproj/project.pbxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ios/NewExpensify.xcodeproj/project.pbxproj b/ios/NewExpensify.xcodeproj/project.pbxproj index d8eceab72b95..cd38fcaaaf6c 100644 --- a/ios/NewExpensify.xcodeproj/project.pbxproj +++ b/ios/NewExpensify.xcodeproj/project.pbxproj @@ -45,7 +45,7 @@ D27CE6B77196EF3EF450EEAC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 0D3F9E814828D91464DF9D35 /* PrivacyInfo.xcprivacy */; }; DD79042B2792E76D004484B4 /* RCTBootSplash.mm in Sources */ = {isa = PBXBuildFile; fileRef = DD79042A2792E76D004484B4 /* RCTBootSplash.mm */; }; DDCB2E57F334C143AC462B43 /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D20D83B0E39BA6D21761E72 /* ExpoModulesProvider.swift */; }; - E51DC681C7DEE40AEBDDFBFE /* (null) in Frameworks */ = {isa = PBXBuildFile; }; + E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */ = {isa = PBXBuildFile; }; E9DF872D2525201700607FDC /* AirshipConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = E9DF872C2525201700607FDC /* AirshipConfig.plist */; }; ED222ED90E074A5481A854FA /* ExpensifyNeue-BoldItalic.otf in Resources */ = {isa = PBXBuildFile; fileRef = 8B28D84EF339436DBD42A203 /* ExpensifyNeue-BoldItalic.otf */; }; F0C450EA2705020500FD2970 /* colors.json in Resources */ = {isa = PBXBuildFile; fileRef = F0C450E92705020500FD2970 /* colors.json */; }; @@ -178,8 +178,8 @@ buildActionMask = 2147483647; files = ( 383643682B6D4AE2005BB9AE /* DeviceCheck.framework in Frameworks */, - E51DC681C7DEE40AEBDDFBFE /* (null) in Frameworks */, - E51DC681C7DEE40AEBDDFBFE /* (null) in Frameworks */, + E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */, + E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */, 8744C5400E24E379441C04A4 /* libPods-NewExpensify.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; From 3b31e9f33777f8f6b68fd3f7cd13b855457f92ff Mon Sep 17 00:00:00 2001 From: c3024 Date: Mon, 11 Nov 2024 20:43:54 +0530 Subject: [PATCH 04/25] troubleshoot LHN alternate text --- src/components/LHNOptionsList/OptionRowLHN.tsx | 1 + src/libs/SidebarUtils.ts | 1 + src/libs/actions/Report.ts | 9 --------- .../BaseOnboardingEmployees.tsx | 16 +++++++++++++++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 94116181bccb..a3662d94b9f2 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -163,6 +163,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const subscriptAvatarBorderColor = isFocused ? focusedBackgroundColor : theme.sidebar; const firstIcon = optionItem.icons?.at(0); + console.log("optionItem ", optionItem); return ( 0 ? ReportUtils.formatReportLastMessageText(Parser.htmlToText(lastMessageText)) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index e32d6cb971d2..fc5345fdd4cc 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3444,15 +3444,6 @@ function completeOnboarding( // const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; console.log("actorAccountID ", actorAccountID, "currentUserAccountID ", currentUserAccountID, "targetChatReport ", targetChatReport, "targetChatReportID ", targetChatReportID, "targetChatPolicyID ", targetChatPolicyID); - if (engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) { - const optimisticPersonalDetailForQAGuide = { - accountID: actorAccountID, - avatar: allPersonalDetails?.[actorAccountID]?.avatar, - displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDES, - login: CONST.EMAIL.QA_GUIDES, - }; - Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); - }; // Introductory message const introductionComment = ReportUtils.buildOptimisticAddCommentReportAction(CONST.ONBOARDING_INTRODUCTION, undefined, actorAccountID); const introductionCommentAction: OptimisticAddCommentReportAction = introductionComment.reportAction; diff --git a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx index 1dd8807cc26e..cb6708d991b0 100644 --- a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx +++ b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx @@ -1,5 +1,5 @@ import React, {useMemo, useState} from 'react'; -import {useOnyx} from 'react-native-onyx'; +import Onyx, {useOnyx} from 'react-native-onyx'; import Button from '@components/Button'; import FormHelpMessage from '@components/FormHelpMessage'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; @@ -32,6 +32,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); const [selectedCompanySize, setSelectedCompanySize] = useState(onboardingCompanySize); const [error, setError] = useState(''); + const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const companySizeOptions: OnboardingListItem[] = useMemo(() => { return Object.values(CONST.ONBOARDING_COMPANY_SIZE).map((companySize): OnboardingListItem => { @@ -43,6 +44,18 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE }); }, [translate, selectedCompanySize]); + const addOptimticQAGuideDetail = () => { + const actorAccountID = CONST.ACCOUNT_ID.QA_GUIDE; + const optimisticPersonalDetailForQAGuide = { + accountID: actorAccountID, + avatar: allPersonalDetails?.[actorAccountID]?.avatar, + displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDES, + login: CONST.EMAIL.QA_GUIDES, + }; + Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); + } + + const footerContent = ( <> {!!error && ( @@ -95,6 +108,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE onSelectRow={(item) => { setSelectedCompanySize(item.keyForList); setError(''); + addOptimticQAGuideDetail(); }} initiallyFocusedOptionKey={companySizeOptions.find((item) => item.keyForList === selectedCompanySize)?.keyForList} shouldUpdateFocusedIndex From ff29d0d8090a110f065cba736ac034e2e95b94d0 Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 12 Nov 2024 21:21:18 +0530 Subject: [PATCH 05/25] fix optimistic lhn message for admins room --- .../LHNOptionsList/OptionRowLHN.tsx | 1 - src/libs/SidebarUtils.ts | 3 --- src/libs/actions/Report.ts | 4 +-- .../BaseOnboardingEmployees.tsx | 26 +++++++++---------- .../BaseOnboardingPurpose.tsx | 1 + src/pages/home/ReportScreen.tsx | 3 +-- 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index a3662d94b9f2..94116181bccb 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -163,7 +163,6 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const subscriptAvatarBorderColor = isFocused ? focusedBackgroundColor : theme.sidebar; const firstIcon = optionItem.icons?.at(0); - console.log("optionItem ", optionItem); return ( | null = report.lastActorAccountID && personalDetails?.[report.lastActorAccountID] ? personalDetails[report.lastActorAccountID] : null; - if (!lastActorDetails && visibleReportActionItems[report.reportID]) { const lastActorDisplayName = visibleReportActionItems[report.reportID]?.person?.[0]?.text; lastActorDetails = lastActorDisplayName @@ -485,7 +483,6 @@ function getOptionData({ } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) { result.alternateText = ReportActionsUtils.getRemovedConnectionMessage(lastAction); } else { - console.log("in the last else block of getOptionData's alternateText ", "reportID: ", report.reportID, "lastAction: ", lastAction); result.alternateText = lastMessageTextFromReport.length > 0 ? ReportUtils.formatReportLastMessageText(Parser.htmlToText(lastMessageText)) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index fc5345fdd4cc..9e0a4ccec116 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3438,12 +3438,9 @@ function completeOnboarding( const integrationName = userReportedIntegration ? CONST.ONBOARDING_ACCOUNTING_MAPPING[userReportedIntegration] : ''; const actorAccountID = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.ACCOUNT_ID.QA_GUIDE : CONST.ACCOUNT_ID.CONCIERGE; - // const actorAccountID = CONST.ACCOUNT_ID.CONCIERGE; const adminsChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`]; const targetChatReport = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); - // const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; - console.log("actorAccountID ", actorAccountID, "currentUserAccountID ", currentUserAccountID, "targetChatReport ", targetChatReport, "targetChatReportID ", targetChatReportID, "targetChatPolicyID ", targetChatPolicyID); // Introductory message const introductionComment = ReportUtils.buildOptimisticAddCommentReportAction(CONST.ONBOARDING_INTRODUCTION, undefined, actorAccountID); const introductionCommentAction: OptimisticAddCommentReportAction = introductionComment.reportAction; @@ -3689,6 +3686,7 @@ function completeOnboarding( lastMentionedTime: DateUtils.getDBTime(), hasOutstandingChildTask, lastVisibleActionCreated, + lastActorAccountID: actorAccountID, }, }, { diff --git a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx index cb6708d991b0..5cc5b2b0890e 100644 --- a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx +++ b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx @@ -32,7 +32,6 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); const [selectedCompanySize, setSelectedCompanySize] = useState(onboardingCompanySize); const [error, setError] = useState(''); - const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const companySizeOptions: OnboardingListItem[] = useMemo(() => { return Object.values(CONST.ONBOARDING_COMPANY_SIZE).map((companySize): OnboardingListItem => { @@ -44,17 +43,18 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE }); }, [translate, selectedCompanySize]); - const addOptimticQAGuideDetail = () => { - const actorAccountID = CONST.ACCOUNT_ID.QA_GUIDE; - const optimisticPersonalDetailForQAGuide = { - accountID: actorAccountID, - avatar: allPersonalDetails?.[actorAccountID]?.avatar, - displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDES, - login: CONST.EMAIL.QA_GUIDES, - }; - Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); - } - + const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); + + const addOptimticQAGuidePersonalDetail = () => { + const actorAccountID = CONST.ACCOUNT_ID.QA_GUIDE; + const optimisticPersonalDetailForQAGuide = { + accountID: actorAccountID, + avatar: allPersonalDetails?.[actorAccountID]?.avatar, + displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDES, + login: CONST.EMAIL.QA_GUIDES, + }; + Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); + }; const footerContent = ( <> @@ -80,6 +80,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM); Welcome.setOnboardingAdminsChatReportID(adminsChatReportID); Welcome.setOnboardingPolicyID(policyID); + addOptimticQAGuidePersonalDetail(); } Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute(route.params?.backTo)); @@ -108,7 +109,6 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE onSelectRow={(item) => { setSelectedCompanySize(item.keyForList); setError(''); - addOptimticQAGuideDetail(); }} initiallyFocusedOptionKey={companySizeOptions.find((item) => item.keyForList === selectedCompanySize)?.keyForList} shouldUpdateFocusedIndex diff --git a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx index 3b05c6bb40a8..703abba69510 100644 --- a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx +++ b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx @@ -84,6 +84,7 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro if (choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) { Navigation.navigate(ROUTES.ONBOARDING_EMPLOYEES.getRoute(route.params?.backTo)); + return; } Navigation.navigate(ROUTES.ONBOARDING_PERSONAL_DETAILS.getRoute(route.params?.backTo)); diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 2b0201b19148..39674d428b29 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -13,6 +13,7 @@ import DragAndDropProvider from '@components/DragAndDrop/Provider'; import MoneyReportHeader from '@components/MoneyReportHeader'; import MoneyRequestHeader from '@components/MoneyRequestHeader'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import {usePersonalDetails} from '@components/OnyxProvider'; import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView'; import ScreenWrapper from '@components/ScreenWrapper'; import TaskHeaderActionButton from '@components/TaskHeaderActionButton'; @@ -55,7 +56,6 @@ import ReportActionsView from './report/ReportActionsView'; import ReportFooter from './report/ReportFooter'; import type {ActionListContextType, ReactionListRef, ScrollPosition} from './ReportScreenContext'; import {ActionListContext, ReactionListContext} from './ReportScreenContext'; -import { usePersonalDetails } from '@components/OnyxProvider'; type ReportScreenNavigationProps = StackScreenProps; @@ -99,7 +99,6 @@ function getParentReportAction(parentReportActions: OnyxEntry Date: Tue, 12 Nov 2024 21:26:49 +0530 Subject: [PATCH 06/25] fix lint --- src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx | 4 ++-- src/pages/home/ReportScreen.tsx | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx index 5cc5b2b0890e..14c8d167a93c 100644 --- a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx +++ b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx @@ -45,7 +45,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); - const addOptimticQAGuidePersonalDetail = () => { + const setOptimticQAGuidePersonalDetail = () => { const actorAccountID = CONST.ACCOUNT_ID.QA_GUIDE; const optimisticPersonalDetailForQAGuide = { accountID: actorAccountID, @@ -80,7 +80,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM); Welcome.setOnboardingAdminsChatReportID(adminsChatReportID); Welcome.setOnboardingPolicyID(policyID); - addOptimticQAGuidePersonalDetail(); + setOptimticQAGuidePersonalDetail(); } Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute(route.params?.backTo)); diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 39674d428b29..dbe6a5badcf4 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -98,7 +98,6 @@ function getParentReportAction(parentReportActions: OnyxEntry Date: Tue, 12 Nov 2024 21:29:22 +0530 Subject: [PATCH 07/25] rename QA_GUIDE --- src/CONST.ts | 2 +- src/libs/actions/Report.ts | 2 +- src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 4624535adc62..489933f3ae43 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1619,7 +1619,7 @@ const CONST = { NOTIFICATIONS: 'notifications@expensify.com', PAYROLL: 'payroll@expensify.com', QA: 'qa@expensify.com', - QA_GUIDES: 'qa.guide@team.expensify.com', + QA_GUIDE: 'qa.guide@team.expensify.com', QA_TRAVIS: 'qa+travisreceipts@expensify.com', RECEIPTS: 'receipts@expensify.com', STUDENT_AMBASSADOR: 'studentambassadors@expensify.com', diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 9e0a4ccec116..2fa4437f0ce9 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3505,7 +3505,7 @@ function completeOnboarding( targetChatPolicyID, CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, ); - const emailCreatingAction = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.EMAIL.QA_GUIDES : CONST.EMAIL.CONCIERGE; + const emailCreatingAction = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.EMAIL.QA_GUIDE : CONST.EMAIL.CONCIERGE; const taskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(emailCreatingAction); const taskReportAction = ReportUtils.buildOptimisticTaskCommentReportAction( currentTask.reportID, diff --git a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx index 14c8d167a93c..e527e50afadd 100644 --- a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx +++ b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx @@ -50,8 +50,8 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const optimisticPersonalDetailForQAGuide = { accountID: actorAccountID, avatar: allPersonalDetails?.[actorAccountID]?.avatar, - displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDES, - login: CONST.EMAIL.QA_GUIDES, + displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDE, + login: CONST.EMAIL.QA_GUIDE, }; Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); }; From 528b1ac07e24a2603bb75893223ce174a088ad25 Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 12 Nov 2024 21:33:07 +0530 Subject: [PATCH 08/25] fix lint --- src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx | 1 + src/pages/home/ReportScreen.tsx | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx index e527e50afadd..d0d2569fb530 100644 --- a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx +++ b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx @@ -53,6 +53,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDE, login: CONST.EMAIL.QA_GUIDE, }; + // eslint-disable-next-line rulesdir/prefer-actions-set-data Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); }; diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index dbe6a5badcf4..4c3ed5c705a5 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -13,7 +13,6 @@ import DragAndDropProvider from '@components/DragAndDrop/Provider'; import MoneyReportHeader from '@components/MoneyReportHeader'; import MoneyRequestHeader from '@components/MoneyRequestHeader'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import {usePersonalDetails} from '@components/OnyxProvider'; import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView'; import ScreenWrapper from '@components/ScreenWrapper'; import TaskHeaderActionButton from '@components/TaskHeaderActionButton'; From c0ee29f818a7d572ae055cb1e92dd04666b2803f Mon Sep 17 00:00:00 2001 From: c3024 Date: Mon, 18 Nov 2024 11:24:14 +0530 Subject: [PATCH 09/25] currentUserAccountID as actor --- src/libs/actions/Report.ts | 4 ++-- .../BaseOnboardingEmployees.tsx | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 514fbe3b44e7..75c88849b3f4 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3494,7 +3494,7 @@ function prepareOnboardingOptimisticData( } const integrationName = userReportedIntegration ? CONST.ONBOARDING_ACCOUNTING_MAPPING[userReportedIntegration] : ''; - const actorAccountID = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.ACCOUNT_ID.QA_GUIDE : CONST.ACCOUNT_ID.CONCIERGE; + const actorAccountID = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? currentUserAccountID : CONST.ACCOUNT_ID.CONCIERGE; const adminsChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`]; const targetChatReport = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; @@ -3567,7 +3567,7 @@ function prepareOnboardingOptimisticData( targetChatPolicyID, CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, ); - const emailCreatingAction = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.EMAIL.QA_GUIDE : CONST.EMAIL.CONCIERGE; + const emailCreatingAction = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? currentUserEmail ?? CONST.EMAIL.CONCIERGE : CONST.EMAIL.CONCIERGE; const taskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(emailCreatingAction); const taskReportAction = ReportUtils.buildOptimisticTaskCommentReportAction( currentTask.reportID, diff --git a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx index ed81bd70a88f..e274d90ee98b 100644 --- a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx +++ b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx @@ -45,17 +45,17 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); - const setOptimticQAGuidePersonalDetail = () => { - const actorAccountID = CONST.ACCOUNT_ID.QA_GUIDE; - const optimisticPersonalDetailForQAGuide = { - accountID: actorAccountID, - avatar: allPersonalDetails?.[actorAccountID]?.avatar, - displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDE, - login: CONST.EMAIL.QA_GUIDE, - }; - // eslint-disable-next-line rulesdir/prefer-actions-set-data - Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); - }; + // const setOptimticQAGuidePersonalDetail = () => { + // const actorAccountID = CONST.ACCOUNT_ID.QA_GUIDE; + // const optimisticPersonalDetailForQAGuide = { + // accountID: actorAccountID, + // avatar: allPersonalDetails?.[actorAccountID]?.avatar, + // displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDE, + // login: CONST.EMAIL.QA_GUIDE, + // }; + // // eslint-disable-next-line rulesdir/prefer-actions-set-data + // Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); + // }; const footerContent = ( <> @@ -81,7 +81,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM); Welcome.setOnboardingAdminsChatReportID(adminsChatReportID); Welcome.setOnboardingPolicyID(policyID); - setOptimticQAGuidePersonalDetail(); + // setOptimticQAGuidePersonalDetail(); } Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute(route.params?.backTo)); From 25801d2c505b400dfbb296f65bdce2b2cc862296 Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 19 Nov 2024 09:13:06 +0530 Subject: [PATCH 10/25] Revert "currentUserAccountID as actor" This reverts commit c0ee29f818a7d572ae055cb1e92dd04666b2803f. --- src/libs/actions/Report.ts | 4 ++-- .../BaseOnboardingEmployees.tsx | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 75c88849b3f4..514fbe3b44e7 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3494,7 +3494,7 @@ function prepareOnboardingOptimisticData( } const integrationName = userReportedIntegration ? CONST.ONBOARDING_ACCOUNTING_MAPPING[userReportedIntegration] : ''; - const actorAccountID = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? currentUserAccountID : CONST.ACCOUNT_ID.CONCIERGE; + const actorAccountID = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.ACCOUNT_ID.QA_GUIDE : CONST.ACCOUNT_ID.CONCIERGE; const adminsChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`]; const targetChatReport = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; @@ -3567,7 +3567,7 @@ function prepareOnboardingOptimisticData( targetChatPolicyID, CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, ); - const emailCreatingAction = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? currentUserEmail ?? CONST.EMAIL.CONCIERGE : CONST.EMAIL.CONCIERGE; + const emailCreatingAction = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.EMAIL.QA_GUIDE : CONST.EMAIL.CONCIERGE; const taskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(emailCreatingAction); const taskReportAction = ReportUtils.buildOptimisticTaskCommentReportAction( currentTask.reportID, diff --git a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx index e274d90ee98b..ed81bd70a88f 100644 --- a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx +++ b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx @@ -45,17 +45,17 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); - // const setOptimticQAGuidePersonalDetail = () => { - // const actorAccountID = CONST.ACCOUNT_ID.QA_GUIDE; - // const optimisticPersonalDetailForQAGuide = { - // accountID: actorAccountID, - // avatar: allPersonalDetails?.[actorAccountID]?.avatar, - // displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDE, - // login: CONST.EMAIL.QA_GUIDE, - // }; - // // eslint-disable-next-line rulesdir/prefer-actions-set-data - // Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); - // }; + const setOptimticQAGuidePersonalDetail = () => { + const actorAccountID = CONST.ACCOUNT_ID.QA_GUIDE; + const optimisticPersonalDetailForQAGuide = { + accountID: actorAccountID, + avatar: allPersonalDetails?.[actorAccountID]?.avatar, + displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDE, + login: CONST.EMAIL.QA_GUIDE, + }; + // eslint-disable-next-line rulesdir/prefer-actions-set-data + Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); + }; const footerContent = ( <> @@ -81,7 +81,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM); Welcome.setOnboardingAdminsChatReportID(adminsChatReportID); Welcome.setOnboardingPolicyID(policyID); - // setOptimticQAGuidePersonalDetail(); + setOptimticQAGuidePersonalDetail(); } Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute(route.params?.backTo)); From b2b933d38a0f598970b078187353be788f5d3dfe Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 19 Nov 2024 10:55:51 +0530 Subject: [PATCH 11/25] remove redundant optimistic introduction message --- src/libs/actions/Report.ts | 115 +++++++++++++++++++++++++------------ 1 file changed, 77 insertions(+), 38 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 514fbe3b44e7..7c2845e83516 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3492,11 +3492,11 @@ function prepareOnboardingOptimisticData( data = CONST.COMBINED_TRACK_SUBMIT_ONBOARDING_MESSAGES[CONST.ONBOARDING_CHOICES.SUBMIT]; } } - + const isEngagementChoiceManageTeam = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM; const integrationName = userReportedIntegration ? CONST.ONBOARDING_ACCOUNTING_MAPPING[userReportedIntegration] : ''; - const actorAccountID = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.ACCOUNT_ID.QA_GUIDE : CONST.ACCOUNT_ID.CONCIERGE; + const actorAccountID = isEngagementChoiceManageTeam ? CONST.ACCOUNT_ID.QA_GUIDE : CONST.ACCOUNT_ID.CONCIERGE; const adminsChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`]; - const targetChatReport = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); + const targetChatReport = isEngagementChoiceManageTeam ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; // Introductory message const introductionComment = ReportUtils.buildOptimisticAddCommentReportAction(CONST.ONBOARDING_INTRODUCTION, undefined, actorAccountID); @@ -3755,7 +3755,6 @@ function prepareOnboardingOptimisticData( onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, value: { - [introductionCommentAction.reportActionID]: introductionCommentAction as ReportAction, [textCommentAction.reportActionID]: textCommentAction as ReportAction, }, }, @@ -3765,6 +3764,18 @@ function prepareOnboardingOptimisticData( value: {choice: engagementChoice}, }, ); + // "Manage team" engagement choice should not add the introduction message + // Backend returns a different introduction message in #admins room for "Manage team" engagement choice + // If we add the introduction message, it will be duplicated in the #admins room + if (!isEngagementChoiceManageTeam) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [introductionCommentAction.reportActionID]: introductionCommentAction as ReportAction, + }, + }); + } if (!wasInvited) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -3774,15 +3785,28 @@ function prepareOnboardingOptimisticData( } const successData: OnyxUpdate[] = [...tasksForSuccessData]; + successData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, value: { - [introductionCommentAction.reportActionID]: {pendingAction: null}, [textCommentAction.reportActionID]: {pendingAction: null}, }, }); + // "Manage team" engagement choice should not add the introduction message + // Backend returns a different introduction message in #admins room for "Manage team" engagement choice + // If we add the introduction message, it will be duplicated in the #admins room + if (!isEngagementChoiceManageTeam) { + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [introductionCommentAction.reportActionID]: {pendingAction: null}, + }, + }); + } + let failureReport: Partial = { lastMessageTranslationKey: '', lastMessageText: '', @@ -3813,9 +3837,6 @@ function prepareOnboardingOptimisticData( onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, value: { - [introductionCommentAction.reportActionID]: { - errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('report.genericAddCommentFailureMessage'), - } as ReportAction, [textCommentAction.reportActionID]: { errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('report.genericAddCommentFailureMessage'), } as ReportAction, @@ -3828,6 +3849,21 @@ function prepareOnboardingOptimisticData( }, ); + // "Manage team" engagement choice should not add the introduction message + // Backend returns a different introduction message in #admins room for "Manage team" engagement choice + // If we add the introduction message, it will be duplicated in the #admins room + if (!isEngagementChoiceManageTeam) { + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [introductionCommentAction.reportActionID]: { + errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('report.genericAddCommentFailureMessage'), + } as ReportAction, + }, + }); + } + if (!wasInvited) { failureData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -3868,39 +3904,42 @@ function prepareOnboardingOptimisticData( }); } - const guidedSetupData: GuidedSetupData = [ - {type: 'message', ...introductionMessage}, - {type: 'message', ...textMessage}, - ]; - - if ('video' in data && data.video && videoCommentAction && videoMessage) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [videoCommentAction.reportActionID]: videoCommentAction as ReportAction, - }, - }); + const guidedSetupData: GuidedSetupData = isEngagementChoiceManageTeam + ? [] + : [ + {type: 'message', ...introductionMessage}, + {type: 'message', ...textMessage}, + ]; + if (!isEngagementChoiceManageTeam) { + if ('video' in data && data.video && videoCommentAction && videoMessage) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [videoCommentAction.reportActionID]: videoCommentAction as ReportAction, + }, + }); - successData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [videoCommentAction.reportActionID]: {pendingAction: null}, - }, - }); + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [videoCommentAction.reportActionID]: {pendingAction: null}, + }, + }); - failureData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [videoCommentAction.reportActionID]: { - errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('report.genericAddCommentFailureMessage'), - } as ReportAction, - }, - }); + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [videoCommentAction.reportActionID]: { + errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('report.genericAddCommentFailureMessage'), + } as ReportAction, + }, + }); - guidedSetupData.push({type: 'video', ...data.video, ...videoMessage}); + guidedSetupData.push({type: 'video', ...data.video, ...videoMessage}); + } } guidedSetupData.push(...tasksForParameters); From ff1669966969ccf8bcbb5320ec0b033eed222f00 Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 19 Nov 2024 17:35:34 +0530 Subject: [PATCH 12/25] remove introduction message --- src/libs/actions/Report.ts | 56 ++------------------------------------ 1 file changed, 2 insertions(+), 54 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 7c2845e83516..4353c4929923 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3498,14 +3498,6 @@ function prepareOnboardingOptimisticData( const adminsChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`]; const targetChatReport = isEngagementChoiceManageTeam ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; - // Introductory message - const introductionComment = ReportUtils.buildOptimisticAddCommentReportAction(CONST.ONBOARDING_INTRODUCTION, undefined, actorAccountID); - const introductionCommentAction: OptimisticAddCommentReportAction = introductionComment.reportAction; - const introductionMessage: AddCommentOrAttachementParams = { - reportID: targetChatReportID, - reportActionID: introductionCommentAction.reportActionID, - reportComment: introductionComment.commentText, - }; // Text message const textComment = ReportUtils.buildOptimisticAddCommentReportAction(data.message, undefined, actorAccountID, 1); @@ -3764,18 +3756,7 @@ function prepareOnboardingOptimisticData( value: {choice: engagementChoice}, }, ); - // "Manage team" engagement choice should not add the introduction message - // Backend returns a different introduction message in #admins room for "Manage team" engagement choice - // If we add the introduction message, it will be duplicated in the #admins room - if (!isEngagementChoiceManageTeam) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [introductionCommentAction.reportActionID]: introductionCommentAction as ReportAction, - }, - }); - } + if (!wasInvited) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -3794,19 +3775,6 @@ function prepareOnboardingOptimisticData( }, }); - // "Manage team" engagement choice should not add the introduction message - // Backend returns a different introduction message in #admins room for "Manage team" engagement choice - // If we add the introduction message, it will be duplicated in the #admins room - if (!isEngagementChoiceManageTeam) { - successData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [introductionCommentAction.reportActionID]: {pendingAction: null}, - }, - }); - } - let failureReport: Partial = { lastMessageTranslationKey: '', lastMessageText: '', @@ -3849,21 +3817,6 @@ function prepareOnboardingOptimisticData( }, ); - // "Manage team" engagement choice should not add the introduction message - // Backend returns a different introduction message in #admins room for "Manage team" engagement choice - // If we add the introduction message, it will be duplicated in the #admins room - if (!isEngagementChoiceManageTeam) { - failureData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [introductionCommentAction.reportActionID]: { - errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('report.genericAddCommentFailureMessage'), - } as ReportAction, - }, - }); - } - if (!wasInvited) { failureData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -3904,12 +3857,7 @@ function prepareOnboardingOptimisticData( }); } - const guidedSetupData: GuidedSetupData = isEngagementChoiceManageTeam - ? [] - : [ - {type: 'message', ...introductionMessage}, - {type: 'message', ...textMessage}, - ]; + const guidedSetupData: GuidedSetupData = [{type: 'message', ...textMessage}]; if (!isEngagementChoiceManageTeam) { if ('video' in data && data.video && videoCommentAction && videoMessage) { optimisticData.push({ From 39dbcc724bcca58ee87ddcb332568b04019da70d Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 19 Nov 2024 17:51:53 +0530 Subject: [PATCH 13/25] retain existing introductory video --- src/libs/actions/Report.ts | 52 ++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 4353c4929923..3334eb7fa927 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3858,36 +3858,34 @@ function prepareOnboardingOptimisticData( } const guidedSetupData: GuidedSetupData = [{type: 'message', ...textMessage}]; - if (!isEngagementChoiceManageTeam) { - if ('video' in data && data.video && videoCommentAction && videoMessage) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [videoCommentAction.reportActionID]: videoCommentAction as ReportAction, - }, - }); + if ('video' in data && data.video && videoCommentAction && videoMessage) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [videoCommentAction.reportActionID]: videoCommentAction as ReportAction, + }, + }); - successData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [videoCommentAction.reportActionID]: {pendingAction: null}, - }, - }); + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [videoCommentAction.reportActionID]: {pendingAction: null}, + }, + }); - failureData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [videoCommentAction.reportActionID]: { - errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('report.genericAddCommentFailureMessage'), - } as ReportAction, - }, - }); + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [videoCommentAction.reportActionID]: { + errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('report.genericAddCommentFailureMessage'), + } as ReportAction, + }, + }); - guidedSetupData.push({type: 'video', ...data.video, ...videoMessage}); - } + guidedSetupData.push({type: 'video', ...data.video, ...videoMessage}); } guidedSetupData.push(...tasksForParameters); From 0362c6f7acf50def9d9575afc0d94faf12b79259 Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 20 Nov 2024 15:19:54 +0530 Subject: [PATCH 14/25] remove needless text break changes --- src/libs/SidebarUtils.ts | 1 + src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 0eb62a8b795c..fe564353371b 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -397,6 +397,7 @@ function getOptionData({ undefined, ReportUtils.isSelfDM(report), ); + // If the last actor's details are not currently saved in Onyx Collection, // then try to get that from the last report action if that action is valid // to get data from. diff --git a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx index 0aa27e1bb380..74d2facf55dc 100644 --- a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx +++ b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx @@ -84,7 +84,6 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro if (choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) { Navigation.navigate(ROUTES.ONBOARDING_EMPLOYEES.getRoute(route.params?.backTo)); - return; } Navigation.navigate(ROUTES.ONBOARDING_PERSONAL_DETAILS.getRoute(route.params?.backTo)); From 6ebfd279d5e142d9c587f7c8add1278602d9f8f6 Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 20 Nov 2024 15:24:17 +0530 Subject: [PATCH 15/25] no changes in SidebarUtils --- src/libs/SidebarUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index fe564353371b..806cebd9bf7f 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -402,6 +402,7 @@ function getOptionData({ // then try to get that from the last report action if that action is valid // to get data from. let lastActorDetails: Partial | null = report.lastActorAccountID && personalDetails?.[report.lastActorAccountID] ? personalDetails[report.lastActorAccountID] : null; + if (!lastActorDetails && visibleReportActionItems[report.reportID]) { const lastActorDisplayName = visibleReportActionItems[report.reportID]?.person?.[0]?.text; lastActorDetails = lastActorDisplayName From 7cb535cb42dcec0695e37c604babd68b11d1b706 Mon Sep 17 00:00:00 2001 From: c3024 Date: Thu, 21 Nov 2024 11:18:03 +0530 Subject: [PATCH 16/25] tooltip on admins room for manageTeam intent --- src/components/LHNOptionsList/OptionRowLHN.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 3e3f4d1b8e5d..fc31360173f2 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -51,6 +51,9 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const [isOnboardingCompleted = true] = useOnyx(ONYXKEYS.NVP_ONBOARDING, { selector: hasCompletedGuidedSetupFlowSelector, }); + const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); + const isOnboardingChoiceManageTeam = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM; + const shouldShowToooltipOnThisReport = isOnboardingChoiceManageTeam ? ReportUtils.isAdminRoom(report) : ReportUtils.isConciergeChatReport(report); const [shouldHideGBRTooltip] = useOnyx(ONYXKEYS.NVP_SHOULD_HIDE_GBR_TOOLTIP, {initialValue: true}); const {translate} = useLocalize(); @@ -173,9 +176,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti needsOffscreenAlphaCompositing > Date: Sat, 23 Nov 2024 06:50:04 +0530 Subject: [PATCH 17/25] post tasks to concierge chat for emails with + --- src/components/LHNOptionsList/OptionRowLHN.tsx | 6 ++++-- src/libs/actions/Report.ts | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index fc31360173f2..0f7fcbba5cda 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -9,6 +9,7 @@ import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; import MultipleAvatars from '@components/MultipleAvatars'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import {useSession} from '@components/OnyxProvider'; import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction'; import SubscriptAvatar from '@components/SubscriptAvatar'; import Text from '@components/Text'; @@ -52,8 +53,9 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti selector: hasCompletedGuidedSetupFlowSelector, }); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); - const isOnboardingChoiceManageTeam = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM; - const shouldShowToooltipOnThisReport = isOnboardingChoiceManageTeam ? ReportUtils.isAdminRoom(report) : ReportUtils.isConciergeChatReport(report); + const session = useSession(); + const isOnboardingGuideAssigned = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !session?.email?.includes('+'); + const shouldShowToooltipOnThisReport = isOnboardingGuideAssigned ? ReportUtils.isAdminRoom(report) : ReportUtils.isConciergeChatReport(report); const [shouldHideGBRTooltip] = useOnyx(ONYXKEYS.NVP_SHOULD_HIDE_GBR_TOOLTIP, {initialValue: true}); const {translate} = useLocalize(); diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 8c38c83b9295..631912f76e6b 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3490,11 +3490,11 @@ function prepareOnboardingOptimisticData( data = CONST.COMBINED_TRACK_SUBMIT_ONBOARDING_MESSAGES[CONST.ONBOARDING_CHOICES.SUBMIT]; } } - const isEngagementChoiceManageTeam = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM; + const shouldPostTasksInAdminsRoom = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+'); const integrationName = userReportedIntegration ? CONST.ONBOARDING_ACCOUNTING_MAPPING[userReportedIntegration] : ''; - const actorAccountID = isEngagementChoiceManageTeam ? CONST.ACCOUNT_ID.QA_GUIDE : CONST.ACCOUNT_ID.CONCIERGE; + const actorAccountID = shouldPostTasksInAdminsRoom ? CONST.ACCOUNT_ID.QA_GUIDE : CONST.ACCOUNT_ID.CONCIERGE; const adminsChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`]; - const targetChatReport = isEngagementChoiceManageTeam ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); + const targetChatReport = shouldPostTasksInAdminsRoom ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; // Text message From bcdb8441eab07ba294d2c2b81f128cff64be52d6 Mon Sep 17 00:00:00 2001 From: c3024 Date: Mon, 25 Nov 2024 14:29:33 +0530 Subject: [PATCH 18/25] clarify why tasks are posted to different reports --- src/components/LHNOptionsList/OptionRowLHN.tsx | 4 ++++ src/libs/actions/Report.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 0f7fcbba5cda..b420e779d8f7 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -54,6 +54,10 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti }); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); const session = useSession(); + + // A guide is assigned to the user if they choose the 'MANAGE_TEAM' onboarding option, except for users with emails containing '+'. + // Onboarding tasks for guide-assigned users are posted in the #admins room. For others, the tasks are posted in the Concierge chat. + // So, we should show the "Get started here" tooltip accordingly on the #admins room or Concierge chat on LHN. const isOnboardingGuideAssigned = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !session?.email?.includes('+'); const shouldShowToooltipOnThisReport = isOnboardingGuideAssigned ? ReportUtils.isAdminRoom(report) : ReportUtils.isConciergeChatReport(report); const [shouldHideGBRTooltip] = useOnyx(ONYXKEYS.NVP_SHOULD_HIDE_GBR_TOOLTIP, {initialValue: true}); diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 631912f76e6b..0e4faacb5b84 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3490,6 +3490,9 @@ function prepareOnboardingOptimisticData( data = CONST.COMBINED_TRACK_SUBMIT_ONBOARDING_MESSAGES[CONST.ONBOARDING_CHOICES.SUBMIT]; } } + + // A guide is assigned to the user if they choose the 'MANAGE_TEAM' onboarding option, except for users with emails containing '+'. + // Onboarding tasks for guide-assigned users are posted in the #admins room. For others, the tasks are posted in the Concierge chat. const shouldPostTasksInAdminsRoom = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+'); const integrationName = userReportedIntegration ? CONST.ONBOARDING_ACCOUNTING_MAPPING[userReportedIntegration] : ''; const actorAccountID = shouldPostTasksInAdminsRoom ? CONST.ACCOUNT_ID.QA_GUIDE : CONST.ACCOUNT_ID.CONCIERGE; From 77ef2c913f3b4f4b223fedaf2622043c76096f8d Mon Sep 17 00:00:00 2001 From: c3024 Date: Mon, 25 Nov 2024 14:38:35 +0530 Subject: [PATCH 19/25] make the comments clearer --- src/components/LHNOptionsList/OptionRowLHN.tsx | 1 + src/libs/actions/Report.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index b420e779d8f7..b9e2e9274e5e 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -56,6 +56,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const session = useSession(); // A guide is assigned to the user if they choose the 'MANAGE_TEAM' onboarding option, except for users with emails containing '+'. + // Posting tasks for users with emails containig '+' in the #admins room is not allowed by the backend. // Onboarding tasks for guide-assigned users are posted in the #admins room. For others, the tasks are posted in the Concierge chat. // So, we should show the "Get started here" tooltip accordingly on the #admins room or Concierge chat on LHN. const isOnboardingGuideAssigned = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !session?.email?.includes('+'); diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 0e4faacb5b84..115a641a90b2 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3492,6 +3492,7 @@ function prepareOnboardingOptimisticData( } // A guide is assigned to the user if they choose the 'MANAGE_TEAM' onboarding option, except for users with emails containing '+'. + // Posting tasks for users with emails containig '+' in the #admins room is not allowed by the backend. // Onboarding tasks for guide-assigned users are posted in the #admins room. For others, the tasks are posted in the Concierge chat. const shouldPostTasksInAdminsRoom = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+'); const integrationName = userReportedIntegration ? CONST.ONBOARDING_ACCOUNTING_MAPPING[userReportedIntegration] : ''; From 5ded7b7d79258cc8fa90dcb8cc7b0bf56169677e Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 26 Nov 2024 12:59:48 +0530 Subject: [PATCH 20/25] use guide email returned in CreatePolicy as actor --- src/CONST.ts | 2 -- src/libs/actions/Report.ts | 19 +++++++++++++++++-- .../BaseOnboardingEmployees.tsx | 15 --------------- src/types/onyx/Policy.ts | 7 +++++++ 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 9a765ac3577b..ee70e3b29668 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1665,7 +1665,6 @@ const CONST = { NOTIFICATIONS: 'notifications@expensify.com', PAYROLL: 'payroll@expensify.com', QA: 'qa@expensify.com', - QA_GUIDE: 'qa.guide@team.expensify.com', QA_TRAVIS: 'qa+travisreceipts@expensify.com', RECEIPTS: 'receipts@expensify.com', STUDENT_AMBASSADOR: 'studentambassadors@expensify.com', @@ -2127,7 +2126,6 @@ const CONST = { NOTIFICATIONS: Number(Config?.EXPENSIFY_ACCOUNT_ID_NOTIFICATIONS ?? 11665625), PAYROLL: Number(Config?.EXPENSIFY_ACCOUNT_ID_PAYROLL ?? 9679724), QA: Number(Config?.EXPENSIFY_ACCOUNT_ID_QA ?? 3126513), - QA_GUIDE: Number(Config?.EXPENSIFY_ACCOUNT_ID_QA_GUIDE ?? 14365522), QA_TRAVIS: Number(Config?.EXPENSIFY_ACCOUNT_ID_QA_TRAVIS ?? 8595733), RECEIPTS: Number(Config?.EXPENSIFY_ACCOUNT_ID_RECEIPTS ?? -1), REWARDS: Number(Config?.EXPENSIFY_ACCOUNT_ID_REWARDS ?? 11023767), // rewards@expensify.com diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index e3a68b3d4e4c..56e94a847abe 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -128,6 +128,7 @@ import { import * as Session from './Session'; import * as Welcome from './Welcome'; import * as OnboardingFlow from './Welcome/OnboardingFlow'; +import { generateAccountID } from '@libs/UserUtils'; type SubscriberCallback = (isFromCurrentUser: boolean, reportActionID: string | undefined) => void; @@ -3494,10 +3495,24 @@ function prepareOnboardingOptimisticData( // Onboarding tasks for guide-assigned users are posted in the #admins room. For others, the tasks are posted in the Concierge chat. const shouldPostTasksInAdminsRoom = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+'); const integrationName = userReportedIntegration ? CONST.ONBOARDING_ACCOUNTING_MAPPING[userReportedIntegration] : ''; - const actorAccountID = shouldPostTasksInAdminsRoom ? CONST.ACCOUNT_ID.QA_GUIDE : CONST.ACCOUNT_ID.CONCIERGE; const adminsChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`]; - const targetChatReport = shouldPostTasksInAdminsRoom ? adminsChatReport : ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); + const targetChatReport = shouldPostTasksInAdminsRoom ? adminsChatReport : ReportUtils.getChatByParticipants([CONST.ACCOUNT_ID.CONCIERGE, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; + const assignedGuideEmail = getPolicy(targetChatPolicyID)?.assignedGuide?.email ?? "Setup Specialist"; + const assignedGuidePersonalDetail = Object.values(allPersonalDetails ?? {}).find((personalDetail) => personalDetail?.login === assignedGuideEmail); + let assignedGuideAccountID : number; + if (assignedGuidePersonalDetail) { + assignedGuideAccountID = assignedGuidePersonalDetail.accountID; + } else { + assignedGuideAccountID = generateAccountID(assignedGuideEmail); + Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, { + [assignedGuideAccountID]: { + login: assignedGuideEmail, + displayName: assignedGuideEmail, + }, + }); + } + const actorAccountID = shouldPostTasksInAdminsRoom ? assignedGuideAccountID : CONST.ACCOUNT_ID.CONCIERGE; // Text message const textComment = ReportUtils.buildOptimisticAddCommentReportAction(data.message, undefined, actorAccountID, 1); diff --git a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx index ed81bd70a88f..68fac2c09eae 100644 --- a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx +++ b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx @@ -43,20 +43,6 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE }); }, [translate, selectedCompanySize]); - const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); - - const setOptimticQAGuidePersonalDetail = () => { - const actorAccountID = CONST.ACCOUNT_ID.QA_GUIDE; - const optimisticPersonalDetailForQAGuide = { - accountID: actorAccountID, - avatar: allPersonalDetails?.[actorAccountID]?.avatar, - displayName: allPersonalDetails?.[actorAccountID]?.displayName ?? CONST.EMAIL.QA_GUIDE, - login: CONST.EMAIL.QA_GUIDE, - }; - // eslint-disable-next-line rulesdir/prefer-actions-set-data - Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[actorAccountID]: optimisticPersonalDetailForQAGuide}); - }; - const footerContent = ( <> {!!error && ( @@ -81,7 +67,6 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM); Welcome.setOnboardingAdminsChatReportID(adminsChatReportID); Welcome.setOnboardingPolicyID(policyID); - setOptimticQAGuidePersonalDetail(); } Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute(route.params?.backTo)); diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 88e41aed5bb4..527a291f9db8 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1842,6 +1842,13 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** Workspace account ID configured for Expensify Card */ workspaceAccountID?: number; + + /** Setup specialist guide assigned for the policy */ + assignedGuide?: { + /** The guide's email */ + email: string; + }; + } & Partial, 'addWorkspaceRoom' | keyof ACHAccount | keyof Attributes >; From 34f5e1b38a0fb17a008e2f770ad60e31207a2bd1 Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 26 Nov 2024 13:01:00 +0530 Subject: [PATCH 21/25] prettier --- src/libs/actions/Report.ts | 6 +++--- src/types/onyx/Policy.ts | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 56e94a847abe..00c3d55533c0 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -87,6 +87,7 @@ import * as ReportUtils from '@libs/ReportUtils'; import {doesReportBelongToWorkspace} from '@libs/ReportUtils'; import shouldSkipDeepLinkNavigation from '@libs/shouldSkipDeepLinkNavigation'; import {getNavatticURL} from '@libs/TourUtils'; +import {generateAccountID} from '@libs/UserUtils'; import Visibility from '@libs/Visibility'; import CONFIG from '@src/CONFIG'; import type {OnboardingAccounting, OnboardingCompanySize} from '@src/CONST'; @@ -128,7 +129,6 @@ import { import * as Session from './Session'; import * as Welcome from './Welcome'; import * as OnboardingFlow from './Welcome/OnboardingFlow'; -import { generateAccountID } from '@libs/UserUtils'; type SubscriberCallback = (isFromCurrentUser: boolean, reportActionID: string | undefined) => void; @@ -3498,9 +3498,9 @@ function prepareOnboardingOptimisticData( const adminsChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`]; const targetChatReport = shouldPostTasksInAdminsRoom ? adminsChatReport : ReportUtils.getChatByParticipants([CONST.ACCOUNT_ID.CONCIERGE, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; - const assignedGuideEmail = getPolicy(targetChatPolicyID)?.assignedGuide?.email ?? "Setup Specialist"; + const assignedGuideEmail = getPolicy(targetChatPolicyID)?.assignedGuide?.email ?? 'Setup Specialist'; const assignedGuidePersonalDetail = Object.values(allPersonalDetails ?? {}).find((personalDetail) => personalDetail?.login === assignedGuideEmail); - let assignedGuideAccountID : number; + let assignedGuideAccountID: number; if (assignedGuidePersonalDetail) { assignedGuideAccountID = assignedGuidePersonalDetail.accountID; } else { diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 527a291f9db8..2628b7b44341 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1848,7 +1848,6 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** The guide's email */ email: string; }; - } & Partial, 'addWorkspaceRoom' | keyof ACHAccount | keyof Attributes >; From de2b8b206daae467029be28185a6c428e5cb4923 Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 26 Nov 2024 13:07:19 +0530 Subject: [PATCH 22/25] fix missing and unused values --- src/libs/actions/Report.ts | 3 ++- src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 00c3d55533c0..702ed69d32a1 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3574,7 +3574,8 @@ function prepareOnboardingOptimisticData( targetChatPolicyID, CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, ); - const emailCreatingAction = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? CONST.EMAIL.QA_GUIDE : CONST.EMAIL.CONCIERGE; + const emailCreatingAction = + engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? allPersonalDetails?.[actorAccountID]?.login ?? CONST.EMAIL.CONCIERGE : CONST.EMAIL.CONCIERGE; const taskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(emailCreatingAction); const taskReportAction = ReportUtils.buildOptimisticTaskCommentReportAction( currentTask.reportID, diff --git a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx index 68fac2c09eae..fee409c6480d 100644 --- a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx +++ b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx @@ -1,5 +1,5 @@ import React, {useMemo, useState} from 'react'; -import Onyx, {useOnyx} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import Button from '@components/Button'; import FormHelpMessage from '@components/FormHelpMessage'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; From 6ec519ffcfc7f796e390eb084971086357342f8b Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 26 Nov 2024 13:28:41 +0530 Subject: [PATCH 23/25] remove optimstic video to avoid duplication --- src/libs/actions/Report.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 702ed69d32a1..97048141080e 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3877,7 +3877,9 @@ function prepareOnboardingOptimisticData( const guidedSetupData: GuidedSetupData = [{type: 'message', ...textMessage}]; - if ('video' in data && data.video && videoCommentAction && videoMessage) { + // If we post tasks in the #admins room, it means that a guide is assigned and this video is sent from the backend. + // If we add an optimistic video message as well, it will be duplicated because backend sends this as-is. + if (!shouldPostTasksInAdminsRoom && 'video' in data && data.video && videoCommentAction && videoMessage) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, From 3d31534a574382bc23be66018d095c7335e66a0f Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 26 Nov 2024 13:59:01 +0530 Subject: [PATCH 24/25] remove duplication of messages --- src/libs/actions/Report.ts | 58 ++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 97048141080e..42ac46e99de9 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3759,13 +3759,6 @@ function prepareOnboardingOptimisticData( lastActorAccountID: actorAccountID, }, }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [textCommentAction.reportActionID]: textCommentAction as ReportAction, - }, - }, { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_INTRO_SELECTED, @@ -3773,6 +3766,17 @@ function prepareOnboardingOptimisticData( }, ); + // If we post tasks in the #admins room, it means that a guide is assigned and all messages except tasks are handled by the backend + if (!shouldPostTasksInAdminsRoom) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [textCommentAction.reportActionID]: textCommentAction as ReportAction, + }, + }); + } + if (!wasInvited) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -3783,13 +3787,16 @@ function prepareOnboardingOptimisticData( const successData: OnyxUpdate[] = [...tasksForSuccessData]; - successData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, - value: { - [textCommentAction.reportActionID]: {pendingAction: null}, - }, - }); + // If we post tasks in the #admins room, it means that a guide is assigned and all messages except tasks are handled by the backend + if (!shouldPostTasksInAdminsRoom) { + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [textCommentAction.reportActionID]: {pendingAction: null}, + }, + }); + } let failureReport: Partial = { lastMessageTranslationKey: '', @@ -3819,7 +3826,16 @@ function prepareOnboardingOptimisticData( key: `${ONYXKEYS.COLLECTION.REPORT}${targetChatReportID}`, value: failureReport, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.NVP_INTRO_SELECTED, + value: {choice: null}, + }, + ); + // If we post tasks in the #admins room, it means that a guide is assigned and all messages except tasks are handled by the backend + if (!shouldPostTasksInAdminsRoom) { + failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, value: { @@ -3827,13 +3843,8 @@ function prepareOnboardingOptimisticData( errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('report.genericAddCommentFailureMessage'), } as ReportAction, }, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.NVP_INTRO_SELECTED, - value: {choice: null}, - }, - ); + }); + } if (!wasInvited) { failureData.push({ @@ -3875,10 +3886,9 @@ function prepareOnboardingOptimisticData( }); } - const guidedSetupData: GuidedSetupData = [{type: 'message', ...textMessage}]; + // If we post tasks in the #admins room, it means that a guide is assigned and all messages except tasks are handled by the backend + const guidedSetupData: GuidedSetupData = shouldPostTasksInAdminsRoom ? [] : [{type: 'message', ...textMessage}]; - // If we post tasks in the #admins room, it means that a guide is assigned and this video is sent from the backend. - // If we add an optimistic video message as well, it will be duplicated because backend sends this as-is. if (!shouldPostTasksInAdminsRoom && 'video' in data && data.video && videoCommentAction && videoMessage) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, From 5c1618e1e2cfcbc872fe10705674a56f1c96a6be Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 27 Nov 2024 15:49:14 +0530 Subject: [PATCH 25/25] make comments concise --- src/components/LHNOptionsList/OptionRowLHN.tsx | 5 +---- src/libs/actions/Report.ts | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index b9e2e9274e5e..8bf19a1edcbf 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -55,10 +55,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); const session = useSession(); - // A guide is assigned to the user if they choose the 'MANAGE_TEAM' onboarding option, except for users with emails containing '+'. - // Posting tasks for users with emails containig '+' in the #admins room is not allowed by the backend. - // Onboarding tasks for guide-assigned users are posted in the #admins room. For others, the tasks are posted in the Concierge chat. - // So, we should show the "Get started here" tooltip accordingly on the #admins room or Concierge chat on LHN. + // Guides are assigned for the MANAGE_TEAM onboarding action, except for emails that have a '+'. const isOnboardingGuideAssigned = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !session?.email?.includes('+'); const shouldShowToooltipOnThisReport = isOnboardingGuideAssigned ? ReportUtils.isAdminRoom(report) : ReportUtils.isConciergeChatReport(report); const [shouldHideGBRTooltip] = useOnyx(ONYXKEYS.NVP_SHOULD_HIDE_GBR_TOOLTIP, {initialValue: true}); diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 42ac46e99de9..2c9a3ec77b49 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3490,9 +3490,7 @@ function prepareOnboardingOptimisticData( } } - // A guide is assigned to the user if they choose the 'MANAGE_TEAM' onboarding option, except for users with emails containing '+'. - // Posting tasks for users with emails containig '+' in the #admins room is not allowed by the backend. - // Onboarding tasks for guide-assigned users are posted in the #admins room. For others, the tasks are posted in the Concierge chat. + // Guides are assigned and tasks are posted in the #admins room for the MANAGE_TEAM onboarding action, except for emails that have a '+'. const shouldPostTasksInAdminsRoom = engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+'); const integrationName = userReportedIntegration ? CONST.ONBOARDING_ACCOUNTING_MAPPING[userReportedIntegration] : ''; const adminsChatReport = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`];