Skip to content

Commit

Permalink
Merge pull request Expensify#53598 from Expensify/revert-52314-wip-mo…
Browse files Browse the repository at this point in the history
…ve-tasks-to-admin-2
  • Loading branch information
blimpich authored Dec 4, 2024
2 parents eff69d6 + f4fdd25 commit ffd18cd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 75 deletions.
11 changes: 3 additions & 8 deletions src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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';
Expand Down Expand Up @@ -52,12 +51,6 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
const [isOnboardingCompleted = true] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
selector: hasCompletedGuidedSetupFlowSelector,
});
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const session = useSession();

// 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});

const {translate} = useLocalize();
Expand Down Expand Up @@ -180,7 +173,9 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
needsOffscreenAlphaCompositing
>
<EducationalTooltip
shouldRender={isFirstTimeNewExpensifyUser && !shouldHideGBRTooltip && isOnboardingCompleted && isScreenFocused && shouldUseNarrowLayout && shouldShowToooltipOnThisReport}
shouldRender={
isFirstTimeNewExpensifyUser && !shouldHideGBRTooltip && isOnboardingCompleted && isScreenFocused && shouldUseNarrowLayout && ReportUtils.isConciergeChatReport(report)
}
renderTooltipContent={renderGBRTooltip}
anchorAlignment={{
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
Expand Down
87 changes: 26 additions & 61 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ 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';
Expand Down Expand Up @@ -3492,27 +3491,10 @@ function prepareOnboardingOptimisticData(
}
}

// 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}`];
const targetChatReport = shouldPostTasksInAdminsRoom ? adminsChatReport : ReportUtils.getChatByParticipants([CONST.ACCOUNT_ID.CONCIERGE, currentUserAccountID]);
const actorAccountID = CONST.ACCOUNT_ID.CONCIERGE;
const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID, 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);
Expand Down Expand Up @@ -3574,9 +3556,7 @@ function prepareOnboardingOptimisticData(
targetChatPolicyID,
CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
);
const emailCreatingAction =
engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? allPersonalDetails?.[actorAccountID]?.login ?? CONST.EMAIL.CONCIERGE : CONST.EMAIL.CONCIERGE;
const taskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(emailCreatingAction);
const taskCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(CONST.EMAIL.CONCIERGE);
const taskReportAction = ReportUtils.buildOptimisticTaskCommentReportAction(
currentTask.reportID,
taskTitle,
Expand Down Expand Up @@ -3756,27 +3736,21 @@ function prepareOnboardingOptimisticData(
lastMentionedTime: DateUtils.getDBTime(),
hasOutstandingChildTask,
lastVisibleActionCreated,
lastActorAccountID: actorAccountID,
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_INTRO_SELECTED,
value: {choice: engagementChoice},
},
);

// 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,
},
});
}

},
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_INTRO_SELECTED,
value: {choice: engagementChoice},
},
);
if (!wasInvited) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -3786,17 +3760,13 @@ function prepareOnboardingOptimisticData(
}

const successData: OnyxUpdate[] = [...tasksForSuccessData];

// 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},
},
});
}
successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
value: {
[textCommentAction.reportActionID]: {pendingAction: null},
},
});

let failureReport: Partial<Report> = {
lastMessageTranslationKey: '',
Expand Down Expand Up @@ -3826,25 +3796,21 @@ 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: {
[textCommentAction.reportActionID]: {
errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('report.genericAddCommentFailureMessage'),
} as ReportAction,
},
});
}
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_INTRO_SELECTED,
value: {choice: null},
},
);

if (!wasInvited) {
failureData.push({
Expand Down Expand Up @@ -3886,10 +3852,9 @@ 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
const guidedSetupData: GuidedSetupData = shouldPostTasksInAdminsRoom ? [] : [{type: 'message', ...textMessage}];
const guidedSetupData: GuidedSetupData = [{type: 'message', ...textMessage}];

if (!shouldPostTasksInAdminsRoom && 'video' in data && data.video && videoCommentAction && videoMessage) {
if ('video' in data && data.video && videoCommentAction && videoMessage) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`,
Expand Down
6 changes: 0 additions & 6 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1842,12 +1842,6 @@ 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<PendingJoinRequestPolicy>,
'addWorkspaceRoom' | keyof ACHAccount | keyof Attributes
>;
Expand Down

0 comments on commit ffd18cd

Please sign in to comment.