Skip to content

Commit 349d003

Browse files
authored
Merge pull request #96355 from lorretheboy/fix-07/73656
(Part 6) Remove Onyx.connect() for the key: ONYXKEYS.PERSONAL_DETAILS_LIST in src/libs/actions/Report.ts
2 parents babfd7d + 8aa1a39 commit 349d003

20 files changed

Lines changed: 118 additions & 11 deletions

src/components/MoneyReportHeaderPrimaryAction/ReviewDuplicatesPrimaryAction.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Button from '@components/ButtonComposed';
2+
import {usePersonalDetails} from '@components/OnyxListItemProvider';
23

34
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
45
import useLocalize from '@hooks/useLocalize';
@@ -28,6 +29,7 @@ import useTransactionThreadData from './useTransactionThreadData';
2829
function ReviewDuplicatesPrimaryAction({reportID, chatReportID}: SimpleActionProps) {
2930
const {translate} = useLocalize();
3031
const {accountID, email} = useCurrentUserPersonalDetails();
32+
const personalDetails = usePersonalDetails();
3133

3234
const {moneyRequestReport, reportActions, transactionThreadReportID} = useTransactionThreadData(reportID, chatReportID);
3335
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(moneyRequestReport?.policyID)}`);
@@ -70,6 +72,7 @@ function ReviewDuplicatesPrimaryAction({reportID, chatReportID}: SimpleActionPro
7072
betas,
7173
iouReport: moneyRequestReport,
7274
iouReportAction: iouAction,
75+
personalDetails,
7376
});
7477
threadID = createdTransactionThreadReport?.reportID;
7578
}

src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {usePersonalDetails} from '@components/OnyxListItemProvider';
12
import PrevNextButtons from '@components/PrevNextButtons';
23
import Text from '@components/Text';
34
import {useWideRHPActions} from '@components/WideRHPContextProvider';
@@ -76,6 +77,7 @@ function MoneyRequestReportTransactionsNavigation({currentTransactionID, isFromR
7677
const [betas] = useOnyx(ONYXKEYS.BETAS);
7778
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
7879
const [hasCompletedGuidedSetupFlow] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasCompletedGuidedSetupFlowSelector});
80+
const personalDetails = usePersonalDetails();
7981

8082
const currentTransactionIndex = transactionIDsList.findIndex((id) => id === currentTransactionID);
8183

@@ -212,7 +214,7 @@ function MoneyRequestReportTransactionsNavigation({currentTransactionID, isFromR
212214
// hydrate it on arrival.
213215
const nextDescriptor = nextTransactionID ? siblingDescriptorsByTransactionID?.[nextTransactionID] : undefined;
214216
if (nextDescriptor) {
215-
const nextReportID = getReportIDToOpenForExpense(nextDescriptor, {introSelected, betas, currentUserEmail: email, currentUserAccountID: accountID});
217+
const nextReportID = getReportIDToOpenForExpense(nextDescriptor, {introSelected, betas, currentUserEmail: email, currentUserAccountID: accountID, personalDetails});
216218
markReportRHPWidth(nextReportID, 'wide');
217219
requestAnimationFrame(() => startTransition(() => Navigation.setParams({reportID: nextReportID, reportActionID: undefined, anchorTransactionID: nextTransactionID, backTo})));
218220
return;
@@ -230,6 +232,7 @@ function MoneyRequestReportTransactionsNavigation({currentTransactionID, isFromR
230232
iouReport: nextTransactionParentReport,
231233
iouReportAction: nextParentReportAction,
232234
transaction: nextTransaction,
235+
personalDetails,
233236
isSelfTourViewed,
234237
hasCompletedGuidedSetupFlow,
235238
});
@@ -265,7 +268,7 @@ function MoneyRequestReportTransactionsNavigation({currentTransactionID, isFromR
265268
// See onNext: resolve the target sibling lazily from its descriptor when present.
266269
const prevDescriptor = prevTransactionID ? siblingDescriptorsByTransactionID?.[prevTransactionID] : undefined;
267270
if (prevDescriptor) {
268-
const prevReportID = getReportIDToOpenForExpense(prevDescriptor, {introSelected, betas, currentUserEmail: email, currentUserAccountID: accountID});
271+
const prevReportID = getReportIDToOpenForExpense(prevDescriptor, {introSelected, betas, currentUserEmail: email, currentUserAccountID: accountID, personalDetails});
269272
markReportRHPWidth(prevReportID, 'wide');
270273
requestAnimationFrame(() => startTransition(() => Navigation.setParams({reportID: prevReportID, reportActionID: undefined, anchorTransactionID: prevTransactionID, backTo})));
271274
return;
@@ -287,6 +290,7 @@ function MoneyRequestReportTransactionsNavigation({currentTransactionID, isFromR
287290
transaction: prevTransaction,
288291
isSelfTourViewed,
289292
hasCompletedGuidedSetupFlow,
293+
personalDetails,
290294
});
291295
const targetReportID = optimisticThread?.reportID ?? prevTransaction.reportID;
292296
markReportRHPWidth(targetReportID, 'wide');

src/components/Search/SearchList/ListItem/TransactionGroupListExpanded.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ActivityIndicator from '@components/ActivityIndicator';
22
import Button from '@components/Button';
33
import OfflineWithFeedback from '@components/OfflineWithFeedback';
4+
import {usePersonalDetails} from '@components/OnyxListItemProvider';
45
import {PressableWithFeedback} from '@components/Pressable';
56
import ScrollView from '@components/ScrollView';
67
import SearchTableHeader from '@components/Search/SearchTableHeader';
@@ -80,6 +81,7 @@ function TransactionGroupListExpandedImpl({
8081
const styles = useThemeStyles();
8182
const {windowWidth} = useWindowDimensions();
8283
const currentUserDetails = useCurrentUserPersonalDetails();
84+
const personalDetails = usePersonalDetails();
8385
const {translate} = useLocalize();
8486
const {getCurrencyDecimals} = useCurrencyListActions();
8587
const [isMobileSelectionModeEnabled] = useOnyx(ONYXKEYS.RAM_ONLY_MOBILE_SELECTION_MODE);
@@ -207,6 +209,7 @@ function TransactionGroupListExpandedImpl({
207209
currentUserLogin: currentUserDetails.email ?? '',
208210
currentUserAccountID: currentUserDetails.accountID,
209211
betas,
212+
personalDetails,
210213
isSelfTourViewed,
211214
hasCompletedGuidedSetupFlow,
212215
IOUTransactionID: transactionItem?.reportAction?.childReportID,
@@ -225,6 +228,7 @@ function TransactionGroupListExpandedImpl({
225228
currentUserLogin: currentUserDetails.email ?? '',
226229
currentUserAccountID: currentUserDetails.accountID,
227230
betas,
231+
personalDetails,
228232
isSelfTourViewed,
229233
hasCompletedGuidedSetupFlow,
230234
IOUTransactionID: transactionItem?.reportAction?.childReportID,

src/components/Search/SearchStaticList.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Checkbox from '@components/Checkbox';
2-
import {useSession} from '@components/OnyxListItemProvider';
2+
import {usePersonalDetails, useSession} from '@components/OnyxListItemProvider';
33
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
44
import SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton';
55
import StatusBadge from '@components/StatusBadge';
@@ -79,6 +79,7 @@ function SearchStaticList({
7979
const {translate, localeCompare, formatPhoneNumber, dateFnsLocale} = useLocalize();
8080
const {getCurrencyDecimals, convertToDisplayString} = useCurrencyListActions();
8181
const session = useSession();
82+
const personalDetails = usePersonalDetails();
8283
const accountID = session?.accountID ?? CONST.DEFAULT_NUMBER_ID;
8384
const email = session?.email;
8485
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
@@ -148,6 +149,7 @@ function SearchStaticList({
148149
currentUserLogin: email ?? '',
149150
currentUserAccountID: accountID,
150151
betas: undefined,
152+
personalDetails,
151153
isSelfTourViewed,
152154
hasCompletedGuidedSetupFlow,
153155
IOUTransactionID: item.reportAction?.childReportID,

src/components/Search/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import FullPageErrorView from '@components/BlockingViews/FullPageErrorView';
22
import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView';
3+
import {usePersonalDetails} from '@components/OnyxListItemProvider';
34
import type {SelectionListHandle} from '@components/SelectionList/types';
45
import SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton';
56
import {useWideRHPActions} from '@components/WideRHPContextProvider';
@@ -165,6 +166,7 @@ function Search({
165166
const previousTransactions = usePrevious(transactions);
166167
const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS);
167168
const {accountID, email} = useCurrentUserPersonalDetails();
169+
const personalDetails = usePersonalDetails();
168170
const isActionLoadingSet = useActionLoadingReportIDs();
169171
const [nonPersonalAndWorkspaceCards] = useOnyx(ONYXKEYS.DERIVED.NON_PERSONAL_AND_WORKSPACE_CARD_LIST);
170172

@@ -583,6 +585,7 @@ function Search({
583585
currentUserLogin: email ?? '',
584586
currentUserAccountID: accountID,
585587
betas,
588+
personalDetails,
586589
isSelfTourViewed,
587590
hasCompletedGuidedSetupFlow,
588591
IOUTransactionID: item?.reportAction?.childReportID,
@@ -645,6 +648,7 @@ function Search({
645648
currentUserLogin: email ?? '',
646649
currentUserAccountID: accountID,
647650
betas,
651+
personalDetails,
648652
isSelfTourViewed,
649653
hasCompletedGuidedSetupFlow,
650654
IOUTransactionID: firstTransaction?.reportAction?.childReportID,
@@ -722,6 +726,7 @@ function Search({
722726
unmarkReportRHPWidth,
723727
introSelected,
724728
betas,
729+
personalDetails,
725730
isSelfTourViewed,
726731
hasCompletedGuidedSetupFlow,
727732
email,

src/hooks/useNavigateToTransactionThread.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {usePersonalDetails} from '@components/OnyxListItemProvider';
12
import {useWideRHPActions} from '@components/WideRHPContextProvider';
23

34
import {createTransactionThreadReport, setOptimisticTransactionThread} from '@libs/actions/Report';
@@ -46,6 +47,7 @@ type NavigateToTransactionThreadParams = {
4647
function useNavigateToTransactionThread() {
4748
const {markReportRHPWidth} = useWideRHPActions();
4849
const currentUserDetails = useCurrentUserPersonalDetails();
50+
const personalDetails = usePersonalDetails();
4951
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
5052
const [betas] = useOnyx(ONYXKEYS.BETAS);
5153

@@ -68,6 +70,7 @@ function useNavigateToTransactionThread() {
6870
iouReport: report,
6971
iouReportAction: iouAction,
7072
transaction,
73+
personalDetails,
7174
});
7275
if (transactionThreadReport) {
7376
reportIDToNavigate = transactionThreadReport.reportID;

src/libs/SearchUIUtils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,6 +2805,9 @@ type CreateAndOpenSearchTransactionThreadParams = {
28052805
/** Beta features list */
28062806
betas: OnyxEntry<OnyxTypes.Beta[]>;
28072807

2808+
/** The personal details of the participants */
2809+
personalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;
2810+
28082811
/** Whether the user has seen the self tour */
28092812
isSelfTourViewed: boolean | undefined;
28102813

@@ -2832,6 +2835,7 @@ function createAndOpenSearchTransactionThread({
28322835
currentUserLogin,
28332836
currentUserAccountID,
28342837
betas,
2838+
personalDetails,
28352839
isSelfTourViewed,
28362840
hasCompletedGuidedSetupFlow,
28372841
IOUTransactionID,
@@ -2874,6 +2878,7 @@ function createAndOpenSearchTransactionThread({
28742878
iouReportAction: reportActionToPass,
28752879
transaction,
28762880
transactionViolations,
2881+
personalDetails,
28772882
isSelfTourViewed,
28782883
hasCompletedGuidedSetupFlow,
28792884
});

src/libs/TransactionThreadNavigationUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {Beta, IntroSelected, Report, ReportAction, Transaction} from '@src/types/onyx';
1+
import type {Beta, IntroSelected, PersonalDetailsList, Report, ReportAction, Transaction} from '@src/types/onyx';
22

33
import type {OnyxEntry} from 'react-native-onyx';
44

@@ -32,6 +32,7 @@ type ResolveReportContext = {
3232
betas: OnyxEntry<Beta[]>;
3333
currentUserEmail: string | undefined;
3434
currentUserAccountID: number;
35+
personalDetails: OnyxEntry<PersonalDetailsList>;
3536
};
3637

3738
/**
@@ -76,6 +77,7 @@ function getReportIDToOpenForExpense(expense: TransactionThreadNavigationDescrip
7677
iouReport: getReportOrDraftReport(reportID) ?? expense.report,
7778
iouReportAction: iouAction,
7879
transaction,
80+
personalDetails: context.personalDetails,
7981
});
8082
return transactionThreadReport?.reportID ?? reportID;
8183
}

src/libs/actions/Report/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,9 +2287,8 @@ type CreateTransactionThreadReportParams = {
22872287
/** The violations for the transaction, if any */
22882288
transactionViolations?: TransactionViolations;
22892289

2290-
// TODO: personalDetails should be a required field in follow-up PRs https://github.com/Expensify/App/issues/73656
22912290
/** The personal details of the participants */
2292-
personalDetails?: OnyxEntry<PersonalDetailsList>;
2291+
personalDetails: OnyxEntry<PersonalDetailsList>;
22932292

22942293
/** Whether the user has seen the self tour */
22952294
// TODO: This will be required eventually. Refactor issue: https://github.com/Expensify/App/issues/66424
@@ -2356,14 +2355,13 @@ function createTransactionThreadReport(params: CreateTransactionThreadReportPara
23562355
if (iouReportAction?.actorAccountID && iouReportAction.actorAccountID !== currentUserAccountID) {
23572356
participantAccountIDsForDetails.push(iouReportAction.actorAccountID);
23582357
}
2359-
const participantLogins = PersonalDetailsUtils.getLoginsByAccountIDs(participantAccountIDsForDetails, personalDetails ?? allPersonalDetails);
2358+
const participantLogins = PersonalDetailsUtils.getLoginsByAccountIDs(participantAccountIDsForDetails, personalDetails);
23602359
const participants = buildParticipantInfoFromLogins(participantLogins);
23612360
openReport({
23622361
reportID: optimisticTransactionThreadReportID,
23632362
introSelected,
23642363
participants,
2365-
// TODO: allPersonalDetails fallback should be removed in follow-up PRs https://github.com/Expensify/App/issues/73656
2366-
personalDetails: personalDetails ?? allPersonalDetails,
2364+
personalDetails,
23672365
newReportObject: optimisticTransactionThread,
23682366
parentReportActionID: iouReportAction?.reportActionID,
23692367
transaction,

src/libs/actions/TransactionInlineEdit.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ function getIouParamsForTransaction({
274274
iouReportAction: resolvedParentReportAction,
275275
transaction,
276276
transactionViolations: transactionViolations ?? undefined,
277+
personalDetails: personalDetailsList,
277278
isSelfTourViewed,
278279
hasCompletedGuidedSetupFlow,
279280
});

0 commit comments

Comments
 (0)