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/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/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 907536704979..44e8f92fa5a0 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -245,6 +245,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'; @@ -295,6 +296,7 @@ type InitMoneyRequestParams = { currentDate: string | undefined; lastSelectedDistanceRates?: OnyxEntry; localeCompare?: (a: string, b: string) => number; + currentUserPersonalDetails: CurrentUserPersonalDetails; }; type MoneyRequestInformation = { @@ -876,11 +878,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; }, }); @@ -1001,6 +1003,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 @@ -1511,7 +1514,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, }, }, { @@ -1775,7 +1778,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, }, }, { @@ -10836,9 +10839,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 = currentUserAccountIDParam === 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 ? currentUserAccountIDParam : undefined; const optimisticSubmittedReportAction = buildOptimisticSubmittedReportAction(expenseReport?.total ?? 0, expenseReport.currency ?? '', expenseReport.reportID, adminAccountID); const optimisticNextStep = buildNextStepNew({ report: expenseReport, @@ -11538,7 +11541,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[] = []; @@ -12627,7 +12630,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) { @@ -12671,9 +12674,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}`]: { @@ -13835,8 +13838,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, diff --git a/src/libs/actions/PersonalDetails.ts b/src/libs/actions/PersonalDetails.ts index 3e44635801b3..ebbae4b5a924 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'; @@ -32,7 +31,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 16c4532b80f6..dca54ab7e654 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} from '@components/LocaleContextProvider'; import * as ActiveClientManager from '@libs/ActiveClientManager'; import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; @@ -192,7 +191,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/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index 057e98b96149..da9bf0b39309 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -666,6 +666,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 5b7fdf4dc83d..8306d9014077 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..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 = { @@ -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 1ce10f28e4fd..700a34a0f6ec 100644 --- a/src/pages/iou/request/IOURequestStartPage.tsx +++ b/src/pages/iou/request/IOURequestStartPage.tsx @@ -95,8 +95,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; @@ -143,6 +146,7 @@ function IOURequestStartPage({ parentReport, currentDate, lastSelectedDistanceRates, + currentUserPersonalDetails, }); // eslint-disable-next-line }, []); @@ -164,9 +168,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. 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 5aa8dcfb0377..6d41b6a0d2cc 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 & { + /** + * Current user's email address + */ + email?: string; +}; + export default PersonalDetails; -export type {Timezone, Status, SelectedTimezone, PersonalDetailsList, PersonalDetailsMetadata}; +export type {Timezone, Status, SelectedTimezone, PersonalDetailsList, PersonalDetailsMetadata, CurrentUserPersonalDetails}; diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index d3684c2ac49c..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,10 +96,12 @@ 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'; 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'; @@ -184,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, @@ -6608,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 ?? '', }, ], }, @@ -6649,6 +6660,7 @@ describe('actions/IOU', () => { report: fakeReport, parentReport: fakeParentReport, currentDate, + currentUserPersonalDetails, }); }) .then(async () => { @@ -6668,6 +6680,7 @@ describe('actions/IOU', () => { report: fakeReport, parentReport: fakeParentReport, currentDate, + currentUserPersonalDetails, }); }) .then(async () => { @@ -6687,6 +6700,7 @@ describe('actions/IOU', () => { report: fakeReport, parentReport: fakeParentReport, currentDate, + currentUserPersonalDetails, }); }) .then(async () => { diff --git a/tests/actions/PersonalDetailsTest.ts b/tests/actions/PersonalDetailsTest.ts index ab09ce90c20f..fa2cfdad3e1c 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 UserAvatarUtils from '@libs/UserAvatarUtils'; 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';