From 57d66da35d748d6d416dda81b4154d181211df16 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Wed, 8 Oct 2025 17:16:06 +0530 Subject: [PATCH 1/4] Remove Onyx.connect() for the key: ONYXKEYS.PERSONAL_DETAILS_LIST in src/libs/actions/Task.ts --- src/libs/actions/QuickActionNavigation.ts | 6 ++-- src/libs/actions/Task.ts | 33 ++++++++++--------- src/pages/home/report/ReportFooter.tsx | 2 +- .../FloatingActionButtonAndPopover.tsx | 8 ++++- src/pages/tasks/TaskAssigneeSelectorModal.tsx | 8 +++-- 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/libs/actions/QuickActionNavigation.ts b/src/libs/actions/QuickActionNavigation.ts index 4f9ecab58b92..0a4433897fbb 100644 --- a/src/libs/actions/QuickActionNavigation.ts +++ b/src/libs/actions/QuickActionNavigation.ts @@ -1,5 +1,6 @@ import {generateReportID} from '@libs/ReportUtils'; import CONST from '@src/CONST'; +import type {PersonalDetails} from '@src/types/onyx'; import type {DistanceExpenseType} from '@src/types/onyx/IOU'; import type {QuickActionName} from '@src/types/onyx/QuickAction'; import type QuickAction from '@src/types/onyx/QuickAction'; @@ -12,6 +13,7 @@ type NavigateToQuickActionParams = { quickAction: QuickAction; selectOption: (onSelected: () => void, shouldRestrictAction: boolean) => void; lastDistanceExpenseType?: DistanceExpenseType; + targetAccountPersonalDetails?: PersonalDetails | null; }; function getQuickActionRequestType(action: QuickActionName | undefined, lastDistanceExpenseType?: DistanceExpenseType): IOURequestType | undefined { @@ -34,7 +36,7 @@ function getQuickActionRequestType(action: QuickActionName | undefined, lastDist } function navigateToQuickAction(params: NavigateToQuickActionParams) { - const {isValidReport, quickAction, selectOption, lastDistanceExpenseType} = params; + const {isValidReport, quickAction, selectOption, lastDistanceExpenseType, targetAccountPersonalDetails} = params; const reportID = isValidReport && quickAction?.chatReportID ? quickAction?.chatReportID : generateReportID(); const requestType = getQuickActionRequestType(quickAction?.action, lastDistanceExpenseType); @@ -53,7 +55,7 @@ function navigateToQuickAction(params: NavigateToQuickActionParams) { selectOption(() => startMoneyRequest(CONST.IOU.TYPE.PAY, reportID, undefined, true), false); break; case CONST.QUICK_ACTIONS.ASSIGN_TASK: - selectOption(() => startOutCreateTaskQuickAction(isValidReport ? reportID : '', quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID), false); + selectOption(() => startOutCreateTaskQuickAction(isValidReport ? reportID : '', quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID, targetAccountPersonalDetails), false); break; case CONST.QUICK_ACTIONS.TRACK_MANUAL: case CONST.QUICK_ACTIONS.TRACK_SCAN: diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 6b3778910764..acf23607337b 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -54,12 +54,6 @@ Onyx.connect({ }, }); -let allPersonalDetails: OnyxEntry; -Onyx.connect({ - key: ONYXKEYS.PERSONAL_DETAILS_LIST, - callback: (value) => (allPersonalDetails = value), -}); - let allReportActions: OnyxCollection; Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, @@ -814,7 +808,7 @@ function setAssigneeChatReport(chatReport: OnyxTypes.Report, isOptimisticReport } } -function setNewOptimisticAssignee(assigneeLogin: string, assigneeAccountID: number) { +function setNewOptimisticAssignee(assigneeLogin: string, assigneeAccountID: number, assigneePersonalDetails?: OnyxTypes.PersonalDetails | null) { const report: ReportUtils.OptimisticChatReport = ReportUtils.buildOptimisticChatReport({ participantList: [assigneeAccountID, currentUserAccountID], reportName: '', @@ -827,8 +821,8 @@ function setNewOptimisticAssignee(assigneeLogin: string, assigneeAccountID: numb const optimisticPersonalDetailsListAction: OnyxTypes.PersonalDetails = { accountID: assigneeAccountID, - avatar: allPersonalDetails?.[assigneeAccountID]?.avatar, - displayName: allPersonalDetails?.[assigneeAccountID]?.displayName ?? assigneeLogin, + avatar: assigneePersonalDetails?.avatar, + displayName: assigneePersonalDetails?.displayName ?? assigneeLogin, login: assigneeLogin, }; Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[assigneeAccountID]: optimisticPersonalDetailsListAction}); @@ -843,6 +837,7 @@ function setNewOptimisticAssignee(assigneeLogin: string, assigneeAccountID: numb function setAssigneeValue( assigneeEmail: string, assigneeAccountID: number, + assigneePersonalDetails?: OnyxTypes.PersonalDetails | null, shareToReportID?: string, chatReport?: OnyxEntry, isCurrentUser = false, @@ -863,7 +858,7 @@ function setAssigneeValue( } // If chat report is still not found we need to build new optimistic chat report if (!report) { - report = setNewOptimisticAssignee(assigneeEmail, assigneeAccountID).assigneeReport; + report = setNewOptimisticAssignee(assigneeEmail, assigneeAccountID, assigneePersonalDetails).assigneeReport; } const reportMetadata = ReportUtils.getReportMetadata(report?.reportID); @@ -905,14 +900,20 @@ function setParentReportID(parentReportID: string) { /** * Clears out the task info from the store and navigates to the NewTaskDetails page */ -function clearOutTaskInfoAndNavigate(reportID?: string, chatReport?: OnyxEntry, accountID = 0, skipConfirmation = false) { +function clearOutTaskInfoAndNavigate( + reportID?: string, + chatReport?: OnyxEntry, + assigneeAccountID = 0, + assigneePersonalDetails?: OnyxTypes.PersonalDetails | null, + skipConfirmation = false, +) { clearOutTaskInfo(skipConfirmation); if (reportID && reportID !== '0') { setParentReportID(reportID); } - if (accountID > 0) { - const accountLogin = allPersonalDetails?.[accountID]?.login ?? ''; - setAssigneeValue(accountLogin, accountID, reportID, chatReport, accountID === currentUserAccountID, skipConfirmation); + if (assigneeAccountID > 0) { + const accountLogin = assigneePersonalDetails?.login ?? ''; + setAssigneeValue(accountLogin, assigneeAccountID, assigneePersonalDetails, reportID, chatReport, assigneeAccountID === currentUserAccountID, skipConfirmation); } Navigation.navigate(ROUTES.NEW_TASK_DETAILS.getRoute(Navigation.getReportRHPActiveRoute())); } @@ -920,12 +921,12 @@ function clearOutTaskInfoAndNavigate(reportID?: string, chatReport?: OnyxEntry value?.login === mentionWithDomain) ?? undefined; if (!Object.keys(assignee ?? {}).length) { const assigneeAccountID = generateAccountID(mentionWithDomain); - const optimisticDataForNewAssignee = setNewOptimisticAssignee(mentionWithDomain, assigneeAccountID); + const optimisticDataForNewAssignee = setNewOptimisticAssignee(mentionWithDomain, assigneeAccountID, assignee); assignee = optimisticDataForNewAssignee.assignee; assigneeChatReport = optimisticDataForNewAssignee.assigneeReport; } diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index b7ccb7a4cc8d..4de4d4649ccd 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -364,7 +364,13 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref showDelegateNoAccessModal(); return; } - navigateToQuickAction({isValidReport, quickAction, selectOption, lastDistanceExpenseType}); + navigateToQuickAction({ + isValidReport, + quickAction, + selectOption, + lastDistanceExpenseType, + targetAccountPersonalDetails: personalDetails?.[quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID], + }); }); }; return [ diff --git a/src/pages/tasks/TaskAssigneeSelectorModal.tsx b/src/pages/tasks/TaskAssigneeSelectorModal.tsx index 404618b20812..f5c7e90f6a95 100644 --- a/src/pages/tasks/TaskAssigneeSelectorModal.tsx +++ b/src/pages/tasks/TaskAssigneeSelectorModal.tsx @@ -5,7 +5,7 @@ import {InteractionManager, View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import {useBetas, useSession} from '@components/OnyxListItemProvider'; +import {useBetas, usePersonalDetails, useSession} from '@components/OnyxListItemProvider'; import {useOptionsList} from '@components/OptionListContextProvider'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionListWithSections'; @@ -118,6 +118,8 @@ function TaskAssigneeSelectorModal() { const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const {userToInvite, recentReports, personalDetails, currentUserOption, searchValue, debouncedSearchValue, setSearchValue, headerMessage, areOptionsInitialized} = useOptions(); + const allPersonalDetails = usePersonalDetails(); + const report: OnyxEntry = useMemo(() => { if (!route.params?.reportID) { return; @@ -189,6 +191,7 @@ function TaskAssigneeSelectorModal() { const assigneeChatReport = setAssigneeValue( option?.login ?? '', option?.accountID ?? CONST.DEFAULT_NUMBER_ID, + allPersonalDetails?.[option?.accountID ?? CONST.DEFAULT_NUMBER_ID], report.reportID, undefined, // passing null as report because for editing task the report will be task details report page not the actual report where task was created isCurrentUser({...option, accountID: option?.accountID ?? CONST.DEFAULT_NUMBER_ID, login: option?.login ?? ''}), @@ -205,6 +208,7 @@ function TaskAssigneeSelectorModal() { setAssigneeValue( option?.login ?? '', option.accountID ?? CONST.DEFAULT_NUMBER_ID, + allPersonalDetails?.[option?.accountID ?? CONST.DEFAULT_NUMBER_ID], task?.shareDestination ?? '', undefined, // passing null as report is null in this condition isCurrentUser({...option, accountID: option?.accountID ?? CONST.DEFAULT_NUMBER_ID, login: option?.login ?? undefined}), @@ -215,7 +219,7 @@ function TaskAssigneeSelectorModal() { }); } }, - [session?.accountID, task?.shareDestination, report, backTo], + [report, allPersonalDetails, session?.accountID, task?.shareDestination, backTo], ); const handleBackButtonPress = useCallback(() => Navigation.goBack(!route.params?.reportID ? ROUTES.NEW_TASK.getRoute(backTo) : backTo), [route.params, backTo]); From 084469bdfaaaee49351a03e92fa6082f72d92981 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 1 Nov 2025 20:36:40 +0530 Subject: [PATCH 2/4] refactor Assignee details --- src/libs/actions/QuickActionNavigation.ts | 4 +-- src/libs/actions/Task.ts | 35 +++++++++---------- .../AttachmentPickerWithMenuItems.tsx | 2 +- src/pages/home/report/ReportFooter.tsx | 6 ++-- .../FloatingActionButtonAndPopover.tsx | 5 ++- src/pages/tasks/TaskAssigneeSelectorModal.tsx | 14 ++++---- 6 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/libs/actions/QuickActionNavigation.ts b/src/libs/actions/QuickActionNavigation.ts index e715b00733ea..3d6b94a8823f 100644 --- a/src/libs/actions/QuickActionNavigation.ts +++ b/src/libs/actions/QuickActionNavigation.ts @@ -13,7 +13,7 @@ type NavigateToQuickActionParams = { quickAction: QuickAction; selectOption: (onSelected: () => void, shouldRestrictAction: boolean) => void; lastDistanceExpenseType?: DistanceExpenseType; - targetAccountPersonalDetails?: PersonalDetails | null; + targetAccountPersonalDetails: PersonalDetails; currentUserAccountID: number; }; @@ -56,7 +56,7 @@ function navigateToQuickAction(params: NavigateToQuickActionParams) { selectOption(() => startMoneyRequest(CONST.IOU.TYPE.PAY, reportID, undefined, true), false); break; case CONST.QUICK_ACTIONS.ASSIGN_TASK: - selectOption(() => startOutCreateTaskQuickAction(currentUserAccountID, isValidReport ? reportID : '', quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID, targetAccountPersonalDetails), false); + selectOption(() => startOutCreateTaskQuickAction(currentUserAccountID, isValidReport ? reportID : '', targetAccountPersonalDetails), false); break; case CONST.QUICK_ACTIONS.TRACK_MANUAL: case CONST.QUICK_ACTIONS.TRACK_SCAN: diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 4e731422b73e..58f3f3353341 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -821,9 +821,9 @@ function setAssigneeChatReport(chatReport: OnyxTypes.Report, isOptimisticReport } } -function setNewOptimisticAssignee(assigneeLogin: string, assigneeAccountID: number, assigneePersonalDetails?: OnyxTypes.PersonalDetails | null, currentUserAccountID: number) { +function setNewOptimisticAssignee(currentUserAccountID: number, assigneePersonalDetails: OnyxTypes.PersonalDetails) { const report: ReportUtils.OptimisticChatReport = ReportUtils.buildOptimisticChatReport({ - participantList: [assigneeAccountID, currentUserAccountID], + participantList: [assigneePersonalDetails.accountID, currentUserAccountID], reportName: '', policyID: CONST.POLICY.OWNER_EMAIL_FAKE, ownerAccountID: CONST.POLICY.OWNER_ACCOUNT_ID_FAKE, @@ -833,12 +833,12 @@ function setNewOptimisticAssignee(assigneeLogin: string, assigneeAccountID: numb Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report); const optimisticPersonalDetailsListAction: OnyxTypes.PersonalDetails = { - accountID: assigneeAccountID, + accountID: assigneePersonalDetails.accountID, avatar: assigneePersonalDetails?.avatar, - displayName: assigneePersonalDetails?.displayName ?? assigneeLogin, - login: assigneeLogin, + displayName: assigneePersonalDetails?.displayName ?? assigneePersonalDetails?.login, + login: assigneePersonalDetails?.login, }; - Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[assigneeAccountID]: optimisticPersonalDetailsListAction}); + Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[assigneePersonalDetails.accountID]: optimisticPersonalDetailsListAction}); return {assignee: optimisticPersonalDetailsListAction, assigneeReport: report}; } @@ -848,10 +848,8 @@ function setNewOptimisticAssignee(assigneeLogin: string, assigneeAccountID: numb * It also sets the shareDestination as that chat report if a share destination isn't already set */ function setAssigneeValue( - assigneeEmail: string, - assigneeAccountID: number, currentUserAccountID: number, - assigneePersonalDetails?: OnyxTypes.PersonalDetails | null, + assigneePersonalDetails: OnyxTypes.PersonalDetails, shareToReportID?: string, chatReport?: OnyxEntry, isCurrentUser = false, @@ -868,11 +866,11 @@ function setAssigneeValue( } else { // Check for the chatReport by participants IDs if (!report) { - report = ReportUtils.getChatByParticipants([assigneeAccountID, currentUserAccountID]); + report = ReportUtils.getChatByParticipants([assigneePersonalDetails.accountID, currentUserAccountID]); } // If chat report is still not found we need to build new optimistic chat report if (!report) { - report = setNewOptimisticAssignee(assigneeEmail, assigneeAccountID, assigneePersonalDetails, currentUserAccountID).assigneeReport; + report = setNewOptimisticAssignee(currentUserAccountID, assigneePersonalDetails).assigneeReport; } const reportMetadata = ReportUtils.getReportMetadata(report?.reportID); @@ -895,7 +893,7 @@ function setAssigneeValue( } // This is only needed for creation of a new task and so it should only be stored locally - Onyx.merge(ONYXKEYS.TASK, {assignee: assigneeEmail, assigneeAccountID}); + Onyx.merge(ONYXKEYS.TASK, {assignee: assigneePersonalDetails?.login ?? '', assigneeAccountID: assigneePersonalDetails.accountID}); // When we're editing the assignee, we immediately call editTaskAssignee. Since setting the assignee is async, // the chatReport is not yet set when editTaskAssignee is called. So we return the chatReport here so that @@ -916,19 +914,18 @@ function setParentReportID(parentReportID: string) { */ function clearOutTaskInfoAndNavigate( currentUserAccountID: number, + assigneePersonalDetails?: OnyxTypes.PersonalDetails, reportID?: string, chatReport?: OnyxEntry, - assigneeAccountID = 0, - assigneePersonalDetails?: OnyxTypes.PersonalDetails | null, skipConfirmation = false, ) { clearOutTaskInfo(skipConfirmation); if (reportID && reportID !== '0') { setParentReportID(reportID); } - if (assigneeAccountID > 0) { - const accountLogin = assigneePersonalDetails?.login ?? ''; - setAssigneeValue(accountLogin, assigneeAccountID, currentUserAccountID, assigneePersonalDetails, reportID, chatReport, assigneeAccountID === currentUserAccountID, skipConfirmation); + const assigneeAccountID = assigneePersonalDetails?.accountID ?? 0; + if (assigneePersonalDetails && assigneeAccountID > 0) { + setAssigneeValue(currentUserAccountID, assigneePersonalDetails, reportID, chatReport, assigneeAccountID === currentUserAccountID, skipConfirmation); } Navigation.navigate(ROUTES.NEW_TASK_DETAILS.getRoute(Navigation.getReportRHPActiveRoute())); } @@ -936,12 +933,12 @@ function clearOutTaskInfoAndNavigate( /** * Start out create task action quick action step */ -function startOutCreateTaskQuickAction(currentUserAccountID: number, reportID: string, targetAccountID: number, targetAccountPersonalDetails?: OnyxTypes.PersonalDetails | null) { +function startOutCreateTaskQuickAction(currentUserAccountID: number, reportID: string, targetAccountPersonalDetails: OnyxTypes.PersonalDetails) { // The second parameter of clearOutTaskInfoAndNavigate is the chat report or DM report // between the user and the person to whom the task is assigned. // Since chatReportID isn't stored in NVP_QUICK_ACTION_GLOBAL_CREATE, we set // it to undefined. This will make setAssigneeValue to search for the correct report. - clearOutTaskInfoAndNavigate(currentUserAccountID, reportID, undefined, targetAccountID, targetAccountPersonalDetails, true); + clearOutTaskInfoAndNavigate(currentUserAccountID, targetAccountPersonalDetails, reportID, undefined, true); } /** diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index f08e161c93fe..5627058eff50 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -305,7 +305,7 @@ function AttachmentPickerWithMenuItems({ icon: Expensicons.Task, text: translate('newTaskPage.assignTask'), shouldCallAfterModalHide: shouldUseNarrowLayout, - onSelected: () => clearOutTaskInfoAndNavigate(currentUserPersonalDetails.accountID, reportID, report), + onSelected: () => clearOutTaskInfoAndNavigate(currentUserPersonalDetails.accountID, undefined, reportID, report), }, ]; }, [report, translate, shouldUseNarrowLayout, currentUserPersonalDetails.accountID, reportID]); diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index c9d265f9a288..559868c2749e 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -144,8 +144,10 @@ function ReportFooter({ if (isValidMention) { assignee = Object.values(allPersonalDetails ?? {}).find((value) => value?.login === mentionWithDomain) ?? undefined; if (!Object.keys(assignee ?? {}).length) { - const assigneeAccountID = generateAccountID(mentionWithDomain); - const optimisticDataForNewAssignee = setNewOptimisticAssignee(mentionWithDomain, assigneeAccountID, assignee, personalDetail.accountID); + const optimisticDataForNewAssignee = setNewOptimisticAssignee(personalDetail.accountID, { + accountID: generateAccountID(mentionWithDomain), + login: mentionWithDomain, + }); assignee = optimisticDataForNewAssignee.assignee; assigneeChatReport = optimisticDataForNewAssignee.assigneeReport; } diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 603a5a6f6595..47df4609e71e 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -428,12 +428,15 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref showDelegateNoAccessModal(); return; } + const targetAccountPersonalDetails = personalDetails?.[quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID] ?? ({} as OnyxTypes.PersonalDetails); + targetAccountPersonalDetails.accountID = targetAccountPersonalDetails?.accountID ?? quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID; + navigateToQuickAction({ isValidReport, quickAction, selectOption, lastDistanceExpenseType, - targetAccountPersonalDetails: personalDetails?.[quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID], + targetAccountPersonalDetails, currentUserAccountID: currentUserPersonalDetails.accountID }); }); diff --git a/src/pages/tasks/TaskAssigneeSelectorModal.tsx b/src/pages/tasks/TaskAssigneeSelectorModal.tsx index 5b103ce16043..86e31f23e370 100644 --- a/src/pages/tasks/TaskAssigneeSelectorModal.tsx +++ b/src/pages/tasks/TaskAssigneeSelectorModal.tsx @@ -144,14 +144,18 @@ function TaskAssigneeSelectorModal() { return; } + const assigneePersonalDetails = { + ...allPersonalDetails?.[option?.accountID ?? CONST.DEFAULT_NUMBER_ID], + accountID: option.accountID ?? CONST.DEFAULT_NUMBER_ID, + login: option.login ?? '', + }; + // Check to see if we're editing a task and if so, update the assignee if (report) { if (option.accountID !== report.managerID) { const assigneeChatReport = setAssigneeValue( - option?.login ?? '', - option?.accountID ?? CONST.DEFAULT_NUMBER_ID, currentUserPersonalDetails.accountID, - allPersonalDetails?.[option?.accountID ?? CONST.DEFAULT_NUMBER_ID], + assigneePersonalDetails, report.reportID, undefined, // passing null as report because for editing task the report will be task details report page not the actual report where task was created isCurrentUser({...option, accountID: option?.accountID ?? CONST.DEFAULT_NUMBER_ID, login: option?.login ?? ''}), @@ -173,10 +177,8 @@ function TaskAssigneeSelectorModal() { // If there's no report, we're creating a new task } else if (option.accountID) { setAssigneeValue( - option?.login ?? '', - option.accountID ?? CONST.DEFAULT_NUMBER_ID, currentUserPersonalDetails.accountID, - allPersonalDetails?.[option?.accountID ?? CONST.DEFAULT_NUMBER_ID], + assigneePersonalDetails, task?.shareDestination ?? '', undefined, // passing null as report is null in this condition isCurrentUser({...option, accountID: option?.accountID ?? CONST.DEFAULT_NUMBER_ID, login: option?.login ?? undefined}), From de4c43e073fd42b47c85133312d8ff552847e5fa Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 1 Nov 2025 20:39:29 +0530 Subject: [PATCH 3/4] formatting --- .../FloatingActionButtonAndPopover.tsx | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 47df4609e71e..d83a34a77d4d 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -429,7 +429,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref return; } const targetAccountPersonalDetails = personalDetails?.[quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID] ?? ({} as OnyxTypes.PersonalDetails); - targetAccountPersonalDetails.accountID = targetAccountPersonalDetails?.accountID ?? quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID; + targetAccountPersonalDetails.accountID = targetAccountPersonalDetails?.accountID ?? quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID; navigateToQuickAction({ isValidReport, @@ -437,7 +437,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref selectOption, lastDistanceExpenseType, targetAccountPersonalDetails, - currentUserAccountID: currentUserPersonalDetails.accountID + currentUserAccountID: currentUserPersonalDetails.accountID, }); }); }; @@ -481,7 +481,30 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref } return []; - }, [translate, styles.pt3, styles.pb2, quickAction, policyChatForActivePolicy, quickActionReport, quickActionPolicy, isReportArchived, isRestrictedToPreferredPolicy, quickActionTitle, quickActionAvatars, quickActionSubtitle, shouldUseNarrowLayout, isDelegateAccessRestricted, isValidReport, selectOption, lastDistanceExpenseType, personalDetails, currentUserPersonalDetails.accountID, showDelegateNoAccessModal, reportID, allTransactionDrafts]); + }, [ + translate, + styles.pt3, + styles.pb2, + quickAction, + policyChatForActivePolicy, + quickActionReport, + quickActionPolicy, + isReportArchived, + isRestrictedToPreferredPolicy, + quickActionTitle, + quickActionAvatars, + quickActionSubtitle, + shouldUseNarrowLayout, + isDelegateAccessRestricted, + isValidReport, + selectOption, + lastDistanceExpenseType, + personalDetails, + currentUserPersonalDetails.accountID, + showDelegateNoAccessModal, + reportID, + allTransactionDrafts, + ]); const isTravelEnabled = useMemo(() => { if (!!isBlockedFromSpotnanaTravel || !primaryContactMethod || Str.isSMSLogin(primaryContactMethod) || !isPaidGroupPolicy(activePolicy)) { From 5bb119dbd6e99dba23c6c484c5d21109a34590c6 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 1 Nov 2025 20:49:06 +0530 Subject: [PATCH 4/4] Updates --- src/libs/actions/Task.ts | 2 +- src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx | 6 ++++-- tests/unit/QuickActionNavigationTest.ts | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 58f3f3353341..e410c8f5c6ae 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -923,7 +923,7 @@ function clearOutTaskInfoAndNavigate( if (reportID && reportID !== '0') { setParentReportID(reportID); } - const assigneeAccountID = assigneePersonalDetails?.accountID ?? 0; + const assigneeAccountID = assigneePersonalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID; if (assigneePersonalDetails && assigneeAccountID > 0) { setAssigneeValue(currentUserAccountID, assigneePersonalDetails, reportID, chatReport, assigneeAccountID === currentUserAccountID, skipConfirmation); } diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index d83a34a77d4d..da9a17aad5b7 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -428,8 +428,10 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref showDelegateNoAccessModal(); return; } - const targetAccountPersonalDetails = personalDetails?.[quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID] ?? ({} as OnyxTypes.PersonalDetails); - targetAccountPersonalDetails.accountID = targetAccountPersonalDetails?.accountID ?? quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID; + const targetAccountPersonalDetails = { + ...personalDetails?.[quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID], + accountID: quickAction.targetAccountID ?? CONST.DEFAULT_NUMBER_ID, + }; navigateToQuickAction({ isValidReport, diff --git a/tests/unit/QuickActionNavigationTest.ts b/tests/unit/QuickActionNavigationTest.ts index d0faffa18fe6..af64b1146740 100644 --- a/tests/unit/QuickActionNavigationTest.ts +++ b/tests/unit/QuickActionNavigationTest.ts @@ -3,6 +3,7 @@ import {navigateToQuickAction} from '@libs/actions/QuickActionNavigation'; import {startOutCreateTaskQuickAction} from '@libs/actions/Task'; import {generateReportID} from '@libs/ReportUtils'; import CONST from '@src/CONST'; +import createPersonalDetails from '../utils/collections/personalDetails'; jest.mock('@libs/actions/IOU', () => ({ startMoneyRequest: jest.fn(), @@ -28,6 +29,7 @@ describe('IOU Utils', () => { selectOption: (onSelected: () => void) => { onSelected(); }, + targetAccountPersonalDetails: createPersonalDetails(1), currentUserAccountID: CONST.DEFAULT_NUMBER_ID, }); @@ -43,6 +45,7 @@ describe('IOU Utils', () => { selectOption: (onSelected: () => void) => { onSelected(); }, + targetAccountPersonalDetails: createPersonalDetails(1), currentUserAccountID: CONST.DEFAULT_NUMBER_ID, }); @@ -58,6 +61,7 @@ describe('IOU Utils', () => { selectOption: (onSelected: () => void) => { onSelected(); }, + targetAccountPersonalDetails: createPersonalDetails(1), currentUserAccountID: CONST.DEFAULT_NUMBER_ID, }); @@ -73,6 +77,7 @@ describe('IOU Utils', () => { selectOption: (onSelected: () => void) => { onSelected(); }, + targetAccountPersonalDetails: createPersonalDetails(1), currentUserAccountID: CONST.DEFAULT_NUMBER_ID, }); @@ -88,6 +93,7 @@ describe('IOU Utils', () => { selectOption: (onSelected: () => void) => { onSelected(); }, + targetAccountPersonalDetails: createPersonalDetails(1), lastDistanceExpenseType: CONST.IOU.REQUEST_TYPE.DISTANCE_MANUAL, currentUserAccountID: CONST.DEFAULT_NUMBER_ID, }); @@ -104,6 +110,7 @@ describe('IOU Utils', () => { selectOption: (onSelected: () => void) => { onSelected(); }, + targetAccountPersonalDetails: createPersonalDetails(1), currentUserAccountID: CONST.DEFAULT_NUMBER_ID, }); @@ -122,6 +129,7 @@ describe('Non IOU quickActions test:', () => { selectOption: (onSelected: () => void) => { onSelected(); }, + targetAccountPersonalDetails: createPersonalDetails(123), currentUserAccountID: CONST.DEFAULT_NUMBER_ID, }); expect(startOutCreateTaskQuickAction).toHaveBeenCalled();