From 327f2740479c003cbb82090eadd8a09471261bd1 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 6 Nov 2025 03:35:44 +0530 Subject: [PATCH 01/10] pass Current user personal details to initMoneyRequest action --- Mobile-Expensify | 2 +- .../Modal/EmployeeTestDriveModal.tsx | 3 +++ src/libs/actions/IOU.ts | 5 ++++- src/pages/Search/SearchPage.tsx | 1 + src/pages/Share/SubmitDetailsPage.tsx | 3 ++- .../useAttachmentUploadValidation.ts | 1 + .../iou/request/DistanceRequestStartPage.tsx | 7 +++++- src/pages/iou/request/IOURequestStartPage.tsx | 22 ++++++++++++++++--- 8 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 90596f6ae77c..c4550135dd56 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 90596f6ae77c45931519b7e28649762654d41ab6 +Subproject commit c4550135dd56f51c1f9db46545324e48e9bd969d diff --git a/src/components/TestDrive/Modal/EmployeeTestDriveModal.tsx b/src/components/TestDrive/Modal/EmployeeTestDriveModal.tsx index a5cf8fc972f5..91990a5dd2f1 100644 --- a/src/components/TestDrive/Modal/EmployeeTestDriveModal.tsx +++ b/src/components/TestDrive/Modal/EmployeeTestDriveModal.tsx @@ -5,6 +5,7 @@ import React, {useCallback, useState} from 'react'; import {InteractionManager} from 'react-native'; import TestReceipt from '@assets/images/fake-test-drive-employee-receipt.jpg'; import TextInput from '@components/TextInput'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useOnboardingMessages from '@hooks/useOnboardingMessages'; import useOnyx from '@hooks/useOnyx'; @@ -43,6 +44,7 @@ function EmployeeTestDriveModal() { const [formError, setFormError] = useState(); const [isLoading, setIsLoading] = useState(false); const {testDrive} = useOnboardingMessages(); + const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const onBossEmailChange = useCallback((value: string) => { setBossEmail(value); @@ -75,6 +77,7 @@ function EmployeeTestDriveModal() { report, parentReport, currentDate, + currentUserPersonalDetails, }); setMoneyRequestReceipt(transactionID, source, filename, true, CONST.TEST_RECEIPT.FILE_TYPE, false, true); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 215a4588b920..e21684bf1744 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -8,6 +8,7 @@ import type {NullishDeep, OnyxCollection, OnyxEntry, OnyxInputValue, OnyxUpdate} import Onyx from 'react-native-onyx'; import type {PartialDeep, SetRequired, ValueOf} from 'type-fest'; import ReceiptGeneric from '@assets/images/receipt-generic.png'; +import {CurrentUserPersonalDetails} from '@components/CurrentUserPersonalDetailsProvider'; import type {PaymentMethod} from '@components/KYCWall/types'; import type {SearchQueryJSON} from '@components/Search/types'; import * as API from '@libs/API'; @@ -297,6 +298,7 @@ type InitMoneyRequestParams = { currentDate: string | undefined; lastSelectedDistanceRates?: OnyxEntry; localeCompare?: (a: string, b: string) => number; + currentUserPersonalDetails: CurrentUserPersonalDetails; }; type MoneyRequestInformation = { @@ -895,7 +897,7 @@ Onyx.connect({ }, }); -let currentUserPersonalDetails: OnyxEntry; +// let currentUserPersonalDetails: OnyxEntry; Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (value) => { @@ -1020,6 +1022,7 @@ function initMoneyRequest({ currentDate = '', lastSelectedDistanceRates, localeCompare, + currentUserPersonalDetails, }: InitMoneyRequestParams) { // Generate a brand new transactionID // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850 diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index ae86767186c2..fbeb5b1406f6 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -595,6 +595,7 @@ function SearchPage({route}: SearchPageProps) { report: newReport, parentReport: newParentReport, currentDate, + currentUserPersonalDetails, }); const newReceiptFiles: ReceiptFile[] = []; diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index 6e7cb02c3ee3..5550dbe9ddd6 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -90,8 +90,9 @@ function SubmitDetailsPage({ report, parentReport, currentDate, + currentUserPersonalDetails, }); - }, [reportOrAccountID, policy, report, parentReport, currentDate]); + }, [reportOrAccountID, policy, report, parentReport, currentDate, currentUserPersonalDetails]); const selectedParticipants = unknownUserDetails ? [unknownUserDetails] : getMoneyRequestParticipantsFromReport(report); const participants = selectedParticipants.map((participant) => diff --git a/src/pages/home/report/ReportActionCompose/useAttachmentUploadValidation.ts b/src/pages/home/report/ReportActionCompose/useAttachmentUploadValidation.ts index ffca8dcedc6e..b176b5ae74bb 100644 --- a/src/pages/home/report/ReportActionCompose/useAttachmentUploadValidation.ts +++ b/src/pages/home/report/ReportActionCompose/useAttachmentUploadValidation.ts @@ -93,6 +93,7 @@ function useAttachmentUploadValidation({ report, parentReport: newParentReport, currentDate, + currentUserPersonalDetails, }); files.forEach((file, index) => { diff --git a/src/pages/iou/request/DistanceRequestStartPage.tsx b/src/pages/iou/request/DistanceRequestStartPage.tsx index c59536c1aa95..88a9e651d85c 100644 --- a/src/pages/iou/request/DistanceRequestStartPage.tsx +++ b/src/pages/iou/request/DistanceRequestStartPage.tsx @@ -5,6 +5,7 @@ import FocusTrapContainerElement from '@components/FocusTrap/FocusTrapContainerE import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import TabSelector from '@components/TabSelector/TabSelector'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import usePolicy from '@hooks/usePolicy'; @@ -55,6 +56,8 @@ function DistanceRequestStartPage({ const [lastSelectedDistanceRates] = useOnyx(ONYXKEYS.NVP_LAST_SELECTED_DISTANCE_RATES, {canBeMissing: true}); const [currentDate] = useOnyx(ONYXKEYS.CURRENT_DATE, {canBeMissing: true}); + const currentUserPersonalDetails = useCurrentUserPersonalDetails(); + const tabTitles = { [CONST.IOU.TYPE.REQUEST]: translate('iou.trackDistance'), [CONST.IOU.TYPE.SUBMIT]: translate('iou.trackDistance'), @@ -103,6 +106,7 @@ function DistanceRequestStartPage({ currentDate, lastSelectedDistanceRates, localeCompare, + currentUserPersonalDetails, }); // eslint-disable-next-line }, []); @@ -124,9 +128,10 @@ function DistanceRequestStartPage({ currentDate, lastSelectedDistanceRates, localeCompare, + currentUserPersonalDetails, }); }, - [transaction?.iouRequestType, reportID, policy, isFromGlobalCreate, report, parentReport, currentDate, lastSelectedDistanceRates, localeCompare], + [transaction?.iouRequestType, reportID, policy, isFromGlobalCreate, report, parentReport, currentDate, lastSelectedDistanceRates, localeCompare, currentUserPersonalDetails], ); // Clear out the temporary expense if the reportID in the URL has changed from the transaction's reportID. diff --git a/src/pages/iou/request/IOURequestStartPage.tsx b/src/pages/iou/request/IOURequestStartPage.tsx index 69d61150bd86..437e4a36ab1e 100644 --- a/src/pages/iou/request/IOURequestStartPage.tsx +++ b/src/pages/iou/request/IOURequestStartPage.tsx @@ -87,8 +87,11 @@ function IOURequestStartPage({ }; const isFromGlobalCreate = isEmptyObject(report?.reportID); - const {login: currentUserLogin} = useCurrentUserPersonalDetails(); - const policiesWithPerDiemEnabled = useMemo(() => getActivePoliciesWithExpenseChatAndPerDiemEnabled(allPolicies, currentUserLogin), [allPolicies, currentUserLogin]); + const currentUserPersonalDetails = useCurrentUserPersonalDetails(); + const policiesWithPerDiemEnabled = useMemo( + () => getActivePoliciesWithExpenseChatAndPerDiemEnabled(allPolicies, currentUserPersonalDetails.login), + [allPolicies, currentUserPersonalDetails.login], + ); const doesPerDiemPolicyExist = policiesWithPerDiemEnabled.length > 0; const moreThanOnePerDiemExist = policiesWithPerDiemEnabled.length > 1; const hasCurrentPolicyPerDiemEnabled = !!policy?.arePerDiemRatesEnabled; @@ -135,6 +138,7 @@ function IOURequestStartPage({ parentReport, currentDate, lastSelectedDistanceRates, + currentUserPersonalDetails, }); // eslint-disable-next-line }, []); @@ -156,9 +160,21 @@ function IOURequestStartPage({ parentReport, currentDate, lastSelectedDistanceRates, + currentUserPersonalDetails, }); }, - [transaction?.iouRequestType, transaction?.isFromGlobalCreate, reportID, policy, isFromGlobalCreate, report, parentReport, currentDate, lastSelectedDistanceRates], + [ + transaction?.iouRequestType, + transaction?.isFromGlobalCreate, + reportID, + policy, + isFromGlobalCreate, + report, + parentReport, + currentDate, + lastSelectedDistanceRates, + currentUserPersonalDetails, + ], ); // Clear out the temporary expense if the reportID in the URL has changed from the transaction's reportID. From 8bebb6326d7c7244aeb6f4c0f2795106e09454e0 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 6 Nov 2025 03:37:08 +0530 Subject: [PATCH 02/10] deprecated the old variable --- src/libs/actions/IOU.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index e21684bf1744..98d37c572fd9 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -897,11 +897,11 @@ Onyx.connect({ }, }); -// let currentUserPersonalDetails: OnyxEntry; +let deprecatedCurrentUserPersonalDetails: OnyxEntry; Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (value) => { - currentUserPersonalDetails = value?.[userAccountID] ?? undefined; + deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined; }, }); @@ -1533,7 +1533,7 @@ function buildOnyxDataForTestDriveIOU(testDriveIOUParams: BuildOnyxDataForTestDr value: { ...{lastActionType: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED}, hasOutstandingChildRequest: false, - lastActorAccountID: currentUserPersonalDetails?.accountID, + lastActorAccountID: deprecatedCurrentUserPersonalDetails?.accountID, }, }, { @@ -1796,7 +1796,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR ...iou.report, ...(!isScanRequest || isTestReceipt ? {lastActionType: CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED} : undefined), hasOutstandingChildRequest: false, - lastActorAccountID: currentUserPersonalDetails?.accountID, + lastActorAccountID: deprecatedCurrentUserPersonalDetails?.accountID, }, }, { @@ -10850,9 +10850,9 @@ function submitReport( const currentNextStep = allNextSteps[`${ONYXKEYS.COLLECTION.NEXT_STEP}${expenseReport.reportID}`] ?? null; const parentReport = getReportOrDraftReport(expenseReport.parentReportID); - const isCurrentUserManager = currentUserPersonalDetails?.accountID === expenseReport.managerID; + const isCurrentUserManager = deprecatedCurrentUserPersonalDetails?.accountID === expenseReport.managerID; const isSubmitAndClosePolicy = isSubmitAndClose(policy); - const adminAccountID = policy?.role === CONST.POLICY.ROLE.ADMIN ? currentUserPersonalDetails?.accountID : undefined; + const adminAccountID = policy?.role === CONST.POLICY.ROLE.ADMIN ? deprecatedCurrentUserPersonalDetails?.accountID : undefined; const optimisticSubmittedReportAction = buildOptimisticSubmittedReportAction(expenseReport?.total ?? 0, expenseReport.currency ?? '', expenseReport.reportID, adminAccountID); const optimisticNextStep = buildNextStepNew({ report: expenseReport, @@ -11550,7 +11550,7 @@ function replaceReceipt({transactionID, file, source, transactionPolicyCategorie function getMoneyRequestParticipantsFromReport(report: OnyxEntry): Participant[] { // If the report is iou or expense report, we should get the chat report to set participant for request money const chatReport = isMoneyRequestReportReportUtils(report) ? getReportOrDraftReport(report?.chatReportID) : report; - const currentUserAccountID = currentUserPersonalDetails?.accountID; + const currentUserAccountID = deprecatedCurrentUserPersonalDetails?.accountID; const shouldAddAsReport = !isEmptyObject(chatReport) && isSelfDM(chatReport); let participants: Participant[] = []; @@ -12636,7 +12636,7 @@ function getSearchOnyxUpdate({ isInvoice, }: GetSearchOnyxUpdateParams): OnyxData | undefined { const toAccountID = participant?.accountID; - const fromAccountID = currentUserPersonalDetails?.accountID; + const fromAccountID = deprecatedCurrentUserPersonalDetails?.accountID; const currentSearchQueryJSON = getCurrentSearchQueryJSON(); if (currentSearchQueryJSON && toAccountID != null && fromAccountID != null) { @@ -12679,9 +12679,9 @@ function getSearchOnyxUpdate({ }, [fromAccountID]: { accountID: fromAccountID, - avatar: currentUserPersonalDetails?.avatar, - displayName: currentUserPersonalDetails?.displayName, - login: currentUserPersonalDetails?.login, + avatar: deprecatedCurrentUserPersonalDetails?.avatar, + displayName: deprecatedCurrentUserPersonalDetails?.displayName, + login: deprecatedCurrentUserPersonalDetails?.login, }, }, [`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`]: { @@ -13837,8 +13837,8 @@ function updateSplitTransactions({ const requestMoneyInformation = { participantParams: { participant: participants.at(0) ?? ({} as Participant), - payeeEmail: currentUserPersonalDetails?.login ?? '', - payeeAccountID: currentUserPersonalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID, + payeeEmail: deprecatedCurrentUserPersonalDetails?.login ?? '', + payeeAccountID: deprecatedCurrentUserPersonalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID, }, policyParams: { policy, From 496647d4405b046367a52e1f9b4ab2e3f7e8c1b1 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 6 Nov 2025 03:37:15 +0530 Subject: [PATCH 03/10] fix type import --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 98d37c572fd9..6e9315ce24d1 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -8,7 +8,7 @@ import type {NullishDeep, OnyxCollection, OnyxEntry, OnyxInputValue, OnyxUpdate} import Onyx from 'react-native-onyx'; import type {PartialDeep, SetRequired, ValueOf} from 'type-fest'; import ReceiptGeneric from '@assets/images/receipt-generic.png'; -import {CurrentUserPersonalDetails} from '@components/CurrentUserPersonalDetailsProvider'; +import type {CurrentUserPersonalDetails} from '@components/CurrentUserPersonalDetailsProvider'; import type {PaymentMethod} from '@components/KYCWall/types'; import type {SearchQueryJSON} from '@components/Search/types'; import * as API from '@libs/API'; From e23de7d51e572e3eeef1e5d6c017c1f830323c35 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 6 Nov 2025 03:44:09 +0530 Subject: [PATCH 04/10] pass Current user personal details to submitReport action --- src/libs/actions/IOU.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 6e9315ce24d1..cf99058d56da 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -10850,9 +10850,9 @@ function submitReport( const currentNextStep = allNextSteps[`${ONYXKEYS.COLLECTION.NEXT_STEP}${expenseReport.reportID}`] ?? null; const parentReport = getReportOrDraftReport(expenseReport.parentReportID); - const isCurrentUserManager = deprecatedCurrentUserPersonalDetails?.accountID === expenseReport.managerID; + const isCurrentUserManager = currentUserAccountIDParam === expenseReport.managerID; const isSubmitAndClosePolicy = isSubmitAndClose(policy); - const adminAccountID = policy?.role === CONST.POLICY.ROLE.ADMIN ? deprecatedCurrentUserPersonalDetails?.accountID : undefined; + const adminAccountID = policy?.role === CONST.POLICY.ROLE.ADMIN ? currentUserAccountIDParam : undefined; const optimisticSubmittedReportAction = buildOptimisticSubmittedReportAction(expenseReport?.total ?? 0, expenseReport.currency ?? '', expenseReport.reportID, adminAccountID); const optimisticNextStep = buildNextStepNew({ report: expenseReport, From ce286c3fe94b26dd739b61dd1dbfd88fa5a415d0 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 6 Nov 2025 04:11:22 +0530 Subject: [PATCH 05/10] fix submodule --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index c4550135dd56..90596f6ae77c 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit c4550135dd56f51c1f9db46545324e48e9bd969d +Subproject commit 90596f6ae77c45931519b7e28649762654d41ab6 From 915854c9842ee2ffc7ef0eec8cae7dad1e5c6cfe Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 6 Nov 2025 04:22:13 +0530 Subject: [PATCH 06/10] Fix tests --- tests/actions/IOUTest.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 43e6519b2cfd..db4721ccdce1 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -6,6 +6,7 @@ import {format} from 'date-fns'; import {deepEqual} from 'fast-equals'; import type {OnyxCollection, OnyxEntry, OnyxInputValue} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; +import createPersonalDetails from 'tests/utils/collections/personalDetails'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; import type {SearchQueryJSON, SearchStatus} from '@components/Search/types'; import useOnyx from '@hooks/useOnyx'; @@ -6576,6 +6577,7 @@ describe('actions/IOU', () => { }); describe('initMoneyRequest', () => { + const currentUserPersonalDetails = createPersonalDetails(RORY_ACCOUNT_ID); const fakeReport: Report = { ...createRandomReport(0, undefined), type: CONST.REPORT.TYPE.EXPENSE, @@ -6646,6 +6648,7 @@ describe('actions/IOU', () => { report: fakeReport, parentReport: fakeParentReport, currentDate, + currentUserPersonalDetails, }); }) .then(async () => { @@ -6665,6 +6668,7 @@ describe('actions/IOU', () => { report: fakeReport, parentReport: fakeParentReport, currentDate, + currentUserPersonalDetails, }); }) .then(async () => { @@ -6684,6 +6688,7 @@ describe('actions/IOU', () => { report: fakeReport, parentReport: fakeParentReport, currentDate, + currentUserPersonalDetails, }); }) .then(async () => { From 22dfa92930c96c63fa7e6d5f86f64b6a6d871607 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Fri, 7 Nov 2025 12:12:46 +0530 Subject: [PATCH 07/10] Fix types --- src/components/CurrentUserPersonalDetailsProvider.tsx | 6 ++---- src/components/withCurrentUserPersonalDetails.tsx | 2 +- src/libs/actions/IOU.ts | 2 +- src/libs/actions/PersonalDetails.ts | 3 +-- src/libs/actions/Report.ts | 3 +-- .../useAttachmentUploadValidation.ts | 2 +- .../settings/Profile/PersonalDetails/LegalNamePage.tsx | 2 +- src/types/onyx/PersonalDetails.ts | 10 +++++++++- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/components/CurrentUserPersonalDetailsProvider.tsx b/src/components/CurrentUserPersonalDetailsProvider.tsx index 759088fcaeb2..81965c11515c 100644 --- a/src/components/CurrentUserPersonalDetailsProvider.tsx +++ b/src/components/CurrentUserPersonalDetailsProvider.tsx @@ -3,11 +3,10 @@ import type {OnyxEntry} from 'react-native-onyx'; import useOnyx from '@hooks/useOnyx'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {PersonalDetails, PersonalDetailsList} from '@src/types/onyx'; +import type {PersonalDetailsList} from '@src/types/onyx'; +import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails'; import {useSession} from './OnyxListItemProvider'; -type CurrentUserPersonalDetails = PersonalDetails & {email?: string}; - const defaultCurrentUserPersonalDetails: CurrentUserPersonalDetails = { accountID: CONST.DEFAULT_NUMBER_ID, }; @@ -32,4 +31,3 @@ function CurrentUserPersonalDetailsProvider({children}: {children: React.ReactNo } export {CurrentUserPersonalDetailsContext, CurrentUserPersonalDetailsProvider}; -export type {CurrentUserPersonalDetails}; diff --git a/src/components/withCurrentUserPersonalDetails.tsx b/src/components/withCurrentUserPersonalDetails.tsx index 0c6234765247..24c6bec99551 100644 --- a/src/components/withCurrentUserPersonalDetails.tsx +++ b/src/components/withCurrentUserPersonalDetails.tsx @@ -2,7 +2,7 @@ import type {ComponentType} from 'react'; import React from 'react'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import getComponentDisplayName from '@libs/getComponentDisplayName'; -import type {CurrentUserPersonalDetails} from './CurrentUserPersonalDetailsProvider'; +import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails'; type HOCProps = { currentUserPersonalDetails: CurrentUserPersonalDetails; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index cf99058d56da..09926ac719bb 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -8,7 +8,6 @@ import type {NullishDeep, OnyxCollection, OnyxEntry, OnyxInputValue, OnyxUpdate} import Onyx from 'react-native-onyx'; import type {PartialDeep, SetRequired, ValueOf} from 'type-fest'; import ReceiptGeneric from '@assets/images/receipt-generic.png'; -import type {CurrentUserPersonalDetails} from '@components/CurrentUserPersonalDetailsProvider'; import type {PaymentMethod} from '@components/KYCWall/types'; import type {SearchQueryJSON} from '@components/Search/types'; import * as API from '@libs/API'; @@ -248,6 +247,7 @@ import type * as OnyxTypes from '@src/types/onyx'; import type {Accountant, Attendee, Participant, Split, SplitExpense} from '@src/types/onyx/IOU'; import type {ErrorFields, Errors, PendingAction, PendingFields} from '@src/types/onyx/OnyxCommon'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; +import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails'; import type {QuickActionName} from '@src/types/onyx/QuickAction'; import type RecentlyUsedTags from '@src/types/onyx/RecentlyUsedTags'; import type {InvoiceReceiver, InvoiceReceiverType} from '@src/types/onyx/Report'; diff --git a/src/libs/actions/PersonalDetails.ts b/src/libs/actions/PersonalDetails.ts index 3a13dd35dc73..9c6d2960f5ae 100644 --- a/src/libs/actions/PersonalDetails.ts +++ b/src/libs/actions/PersonalDetails.ts @@ -1,6 +1,5 @@ import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; -import type {CurrentUserPersonalDetails} from '@components/CurrentUserPersonalDetailsProvider'; import type {FormOnyxValues} from '@components/Form/types'; import type {LocaleContextProps} from '@components/LocaleContextProvider'; import * as API from '@libs/API'; @@ -31,7 +30,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {DateOfBirthForm} from '@src/types/form'; import type {PersonalDetails} from '@src/types/onyx'; -import type {SelectedTimezone, Timezone} from '@src/types/onyx/PersonalDetails'; +import type {CurrentUserPersonalDetails, SelectedTimezone, Timezone} from '@src/types/onyx/PersonalDetails'; import type {Address} from '@src/types/onyx/PrivatePersonalDetails'; function updatePronouns(pronouns: string, currentUserAccountID: number) { diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 4841cd587d6e..946c8f401f8b 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -7,7 +7,6 @@ import type {NullishDeep, OnyxCollection, OnyxCollectionInputValue, OnyxEntry, O import Onyx from 'react-native-onyx'; import type {PartialDeep, ValueOf} from 'type-fest'; import type {Emoji} from '@assets/emojis/types'; -import type {CurrentUserPersonalDetails} from '@components/CurrentUserPersonalDetailsProvider'; import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider'; import * as ActiveClientManager from '@libs/ActiveClientManager'; import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; @@ -203,7 +202,7 @@ import type { TransactionViolations, } from '@src/types/onyx'; import type {Decision} from '@src/types/onyx/OriginalMessage'; -import type {Timezone} from '@src/types/onyx/PersonalDetails'; +import type {CurrentUserPersonalDetails, Timezone} from '@src/types/onyx/PersonalDetails'; import type {ConnectionName} from '@src/types/onyx/Policy'; import type {NotificationPreference, Participants, Participant as ReportParticipant, RoomVisibility, WriteCapability} from '@src/types/onyx/Report'; import type {Message, ReportActions} from '@src/types/onyx/ReportAction'; diff --git a/src/pages/home/report/ReportActionCompose/useAttachmentUploadValidation.ts b/src/pages/home/report/ReportActionCompose/useAttachmentUploadValidation.ts index b176b5ae74bb..d9caf6d74982 100644 --- a/src/pages/home/report/ReportActionCompose/useAttachmentUploadValidation.ts +++ b/src/pages/home/report/ReportActionCompose/useAttachmentUploadValidation.ts @@ -1,6 +1,5 @@ import {useCallback, useContext, useRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; -import type {CurrentUserPersonalDetails} from '@components/CurrentUserPersonalDetailsProvider'; import useFilesValidation from '@hooks/useFilesValidation'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -16,6 +15,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; +import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails'; import type {FileObject} from '@src/types/utils/Attachment'; type AttachmentUploadValidationProps = { diff --git a/src/pages/settings/Profile/PersonalDetails/LegalNamePage.tsx b/src/pages/settings/Profile/PersonalDetails/LegalNamePage.tsx index 51b963e714f3..c5fd72955d8e 100644 --- a/src/pages/settings/Profile/PersonalDetails/LegalNamePage.tsx +++ b/src/pages/settings/Profile/PersonalDetails/LegalNamePage.tsx @@ -1,6 +1,5 @@ import React, {useCallback} from 'react'; import {View} from 'react-native'; -import type {CurrentUserPersonalDetails} from '@components/CurrentUserPersonalDetailsProvider'; import DelegateNoAccessWrapper from '@components/DelegateNoAccessWrapper'; import FormProvider from '@components/Form/FormProvider'; import InputWrapper from '@components/Form/InputWrapper'; @@ -23,6 +22,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/LegalNameForm'; import type {PrivatePersonalDetails} from '@src/types/onyx'; import type {Errors} from '@src/types/onyx/OnyxCommon'; +import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails'; const updateLegalName = ( values: PrivatePersonalDetails, diff --git a/src/types/onyx/PersonalDetails.ts b/src/types/onyx/PersonalDetails.ts index 8ebb19743d0f..ecf117e6e4cb 100644 --- a/src/types/onyx/PersonalDetails.ts +++ b/src/types/onyx/PersonalDetails.ts @@ -93,6 +93,14 @@ type PersonalDetailsMetadata = { /** Record of user personal details, indexed by user id */ type PersonalDetailsList = Record; +/** Current user's personal details */ +type CurrentUserPersonalDetails = PersonalDetails & { + /** + * Curent user's email address + */ + email?: string; +}; + export default PersonalDetails; -export type {Timezone, Status, SelectedTimezone, PersonalDetailsList, PersonalDetailsMetadata}; +export type {Timezone, Status, SelectedTimezone, PersonalDetailsList, PersonalDetailsMetadata, CurrentUserPersonalDetails}; From 5236d9cd6be94d7f6972abf7f3084cc608befafd Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Fri, 7 Nov 2025 12:13:23 +0530 Subject: [PATCH 08/10] Fix tests --- tests/actions/IOUTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index db4721ccdce1..d26128a6e9b3 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -6,7 +6,6 @@ import {format} from 'date-fns'; import {deepEqual} from 'fast-equals'; import type {OnyxCollection, OnyxEntry, OnyxInputValue} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; -import createPersonalDetails from 'tests/utils/collections/personalDetails'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; import type {SearchQueryJSON, SearchStatus} from '@components/Search/types'; import useOnyx from '@hooks/useOnyx'; @@ -100,6 +99,7 @@ import {changeTransactionsReport} from '../../src/libs/actions/Transaction'; import type {InvoiceTestData} from '../data/Invoice'; import * as InvoiceData from '../data/Invoice'; import currencyList from '../unit/currencyList.json'; +import createPersonalDetails from '../utils/collections/personalDetails'; import createRandomPolicy, {createCategoryTaxExpenseRules} from '../utils/collections/policies'; import createRandomPolicyCategories from '../utils/collections/policyCategory'; import createRandomPolicyTags from '../utils/collections/policyTags'; From f0044b6957d814633454c987c39bdb67149c6eb6 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Wed, 12 Nov 2025 00:45:02 +0530 Subject: [PATCH 09/10] Fix tests --- src/types/onyx/PersonalDetails.ts | 2 +- tests/actions/PersonalDetailsTest.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/onyx/PersonalDetails.ts b/src/types/onyx/PersonalDetails.ts index ecf117e6e4cb..2824fd856973 100644 --- a/src/types/onyx/PersonalDetails.ts +++ b/src/types/onyx/PersonalDetails.ts @@ -96,7 +96,7 @@ type PersonalDetailsList = Record; /** Current user's personal details */ type CurrentUserPersonalDetails = PersonalDetails & { /** - * Curent user's email address + * Current user's email address */ email?: string; }; diff --git a/tests/actions/PersonalDetailsTest.ts b/tests/actions/PersonalDetailsTest.ts index 0d53a47f19ee..ef05d21dfba4 100644 --- a/tests/actions/PersonalDetailsTest.ts +++ b/tests/actions/PersonalDetailsTest.ts @@ -1,6 +1,5 @@ /* eslint-disable no-restricted-syntax */ import Onyx from 'react-native-onyx'; -import type {CurrentUserPersonalDetails} from '@components/CurrentUserPersonalDetailsProvider'; import * as API from '@libs/API'; import {WRITE_COMMANDS} from '@libs/API/types'; import type {CustomRNImageManipulatorResult} from '@libs/cropOrRotateImage/types'; @@ -10,6 +9,7 @@ import * as UserUtils from '@libs/UserUtils'; import CONST from '@src/CONST'; import type {Country} from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails'; import type {Address} from '@src/types/onyx/PrivatePersonalDetails'; import * as PersonalDetailsActions from '../../src/libs/actions/PersonalDetails'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; From b9806892f182323d223e3481bcadb327a1a04813 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Wed, 12 Nov 2025 01:14:48 +0530 Subject: [PATCH 10/10] FIx tests --- tests/actions/IOUTest.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 7d042350a46d..62b9add935f6 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -88,6 +88,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {OriginalMessageIOU, PersonalDetailsList, Policy, PolicyTagLists, Report, ReportNameValuePairs, SearchResults} from '@src/types/onyx'; import type {Accountant, Attendee} from '@src/types/onyx/IOU'; +import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails'; import type {Participant, ReportCollectionDataSet} from '@src/types/onyx/Report'; import type ReportAction from '@src/types/onyx/ReportAction'; import type {ReportActions, ReportActionsCollectionDataSet} from '@src/types/onyx/ReportAction'; @@ -95,6 +96,7 @@ import type Transaction from '@src/types/onyx/Transaction'; import type {TransactionCollectionDataSet} from '@src/types/onyx/Transaction'; import {toCollectionDataSet} from '@src/types/utils/CollectionDataSet'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import SafeString from '@src/utils/SafeString'; import {changeTransactionsReport} from '../../src/libs/actions/Transaction'; import type {InvoiceTestData} from '../data/Invoice'; import * as InvoiceData from '../data/Invoice'; @@ -185,6 +187,14 @@ const VIT_PARTICIPANT: Participant = {notificationPreference: CONST.REPORT.NOTIF OnyxUpdateManager(); describe('actions/IOU', () => { + const currentUserPersonalDetails: CurrentUserPersonalDetails = { + ...createPersonalDetails(RORY_ACCOUNT_ID), + login: RORY_EMAIL, + email: RORY_EMAIL, + displayName: RORY_EMAIL, + avatar: 'https://example.com/avatar.jpg', + }; + beforeAll(() => { Onyx.init({ keys: ONYXKEYS, @@ -6580,7 +6590,6 @@ describe('actions/IOU', () => { }); describe('initMoneyRequest', () => { - const currentUserPersonalDetails = createPersonalDetails(RORY_ACCOUNT_ID); const fakeReport: Report = { ...createRandomReport(0, undefined), type: CONST.REPORT.TYPE.EXPENSE, @@ -6610,14 +6619,14 @@ describe('actions/IOU', () => { comment: { attendees: [ { - email: 'rory@expensifail.com', - login: 'rory@expensifail.com', + email: currentUserPersonalDetails.email ?? '', + login: currentUserPersonalDetails.login, accountID: 3, - text: 'rory@expensifail.com', + text: currentUserPersonalDetails.login, selected: true, reportID: '0', - avatarUrl: '', - displayName: '', + avatarUrl: SafeString(currentUserPersonalDetails.avatar) ?? '', + displayName: currentUserPersonalDetails.displayName ?? '', }, ], },