Skip to content

Commit 4ebab2d

Browse files
committed
changes after review
1 parent 1210621 commit 4ebab2d

7 files changed

Lines changed: 23 additions & 20 deletions

File tree

src/pages/Debug/ReportAction/DebugReportActionCreatePage.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ function DebugReportActionCreatePage({
128128
isUserValidated={isUserValidated}
129129
personalDetails={personalDetailsList}
130130
userBillingFundID={userBillingFundID}
131-
draftMessage={undefined}
132-
emojiReactions={undefined}
133-
linkedTransactionRouteError={undefined}
134131
/>
135132
) : (
136133
<Text>{translate('debug.nothingToPreview')}</Text>

src/pages/Debug/ReportAction/DebugReportActionPreview.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import type {OnyxEntry} from 'react-native-onyx';
3+
import {usePersonalDetails} from '@components/OnyxListItemProvider';
34
import ScrollView from '@components/ScrollView';
45
import useOnyx from '@hooks/useOnyx';
56
import ReportActionItem from '@pages/home/report/ReportActionItem';
@@ -19,7 +20,7 @@ function DebugReportActionPreview({reportAction, reportID}: DebugReportActionPre
1920
const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false});
2021
const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET, {canBeMissing: true});
2122
const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: true});
22-
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: true});
23+
const personalDetails = usePersonalDetails();
2324
const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID, {canBeMissing: true});
2425
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
2526

src/pages/TransactionDuplicate/DuplicateTransactionItem.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import React from 'react';
22
import {View} from 'react-native';
33
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
4+
import {usePersonalDetails} from '@components/OnyxListItemProvider';
45
import useOnyx from '@hooks/useOnyx';
56
import useThemeStyles from '@hooks/useThemeStyles';
67
import {getOriginalMessage, getReportAction, isMoneyRequestAction} from '@libs/ReportActionsUtils';
78
import {getOriginalReportID} from '@libs/ReportUtils';
89
import ReportActionItem from '@pages/home/report/ReportActionItem';
910
import CONST from '@src/CONST';
1011
import ONYXKEYS from '@src/ONYXKEYS';
11-
import type {Policy, Report, ReportActionsDrafts, Transaction} from '@src/types/onyx';
12+
import type {Policy, Report, Transaction} from '@src/types/onyx';
1213

1314
type DuplicateTransactionItemProps = {
1415
transaction: OnyxEntry<Transaction>;
@@ -22,7 +23,7 @@ function DuplicateTransactionItem({transaction, index, allReports, policies}: Du
2223
const styles = useThemeStyles();
2324
const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET, {canBeMissing: true});
2425
const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: true});
25-
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: true});
26+
const personalDetails = usePersonalDetails();
2627
const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID, {canBeMissing: true});
2728
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`];
2829
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`, {canBeMissing: false});
@@ -52,6 +53,9 @@ function DuplicateTransactionItem({transaction, index, allReports, policies}: Du
5253
return null;
5354
}
5455

56+
const reportDraftMessage = draftMessage?.[action.reportActionID];
57+
const matchingDraftMessage = typeof reportDraftMessage === 'string' ? reportDraftMessage : reportDraftMessage?.message;
58+
5559
return (
5660
<View style={styles.pb2}>
5761
<ReportActionItem
@@ -70,7 +74,7 @@ function DuplicateTransactionItem({transaction, index, allReports, policies}: Du
7074
userWallet={userWallet}
7175
isUserValidated={isUserValidated}
7276
personalDetails={personalDetails}
73-
draftMessage={draftMessage as OnyxEntry<string & ReportActionsDrafts>}
77+
draftMessage={matchingDraftMessage}
7478
emojiReactions={emojiReactions}
7579
linkedTransactionRouteError={linkedTransactionRouteError}
7680
userBillingFundID={userBillingFundID}

src/pages/home/report/ReportActionItem.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {clearAllRelatedReportActionErrors} from '@userActions/ReportActions';
2727
import {clearError} from '@userActions/Transaction';
2828
import type CONST from '@src/CONST';
2929
import ONYXKEYS from '@src/ONYXKEYS';
30-
import type {PersonalDetailsList, Policy, Report, ReportAction, ReportActionReactions, ReportActionsDrafts, Transaction, UserWallet} from '@src/types/onyx';
30+
import type {PersonalDetailsList, Policy, Report, ReportAction, ReportActionReactions, Transaction, UserWallet} from '@src/types/onyx';
3131
import type {Errors} from '@src/types/onyx/OnyxCommon';
3232
import type {PureReportActionItemProps} from './PureReportActionItem';
3333
import PureReportActionItem from './PureReportActionItem';
@@ -46,7 +46,7 @@ type ReportActionItemProps = Omit<PureReportActionItemProps, 'taskReport' | 'lin
4646
transactions?: Array<OnyxEntry<Transaction>>;
4747

4848
/** Draft message for the report action */
49-
draftMessage?: OnyxEntry<string & ReportActionsDrafts> | undefined;
49+
draftMessage?: string;
5050

5151
/** Emoji reactions for the report action */
5252
emojiReactions?: OnyxEntry<ReportActionReactions>;
@@ -89,8 +89,6 @@ function ReportActionItem({
8989
const originalReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`];
9090
const isOriginalReportArchived = useReportIsArchived(originalReportID);
9191

92-
const matchingDraftMessage = draftMessage?.[action.reportActionID];
93-
const matchingDraftMessageString = typeof matchingDraftMessage === 'string' ? matchingDraftMessage : matchingDraftMessage?.message;
9492
const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${getIOUReportIDFromReportActionPreview(action)}`];
9593
const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];
9694
// The app would crash due to subscribing to the entire report collection if parentReportID is an empty string. So we should have a fallback ID here.
@@ -113,7 +111,7 @@ function ReportActionItem({
113111
action={action}
114112
report={report}
115113
policy={policy}
116-
draftMessage={matchingDraftMessageString}
114+
draftMessage={draftMessage}
117115
iouReport={iouReport}
118116
taskReport={taskReport}
119117
linkedReport={linkedReport}

src/pages/home/report/ReportActionItemParentAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type ReportActionItemParentActionProps = {
7272
personalDetails?: OnyxEntry<OnyxTypes.PersonalDetailsList>;
7373

7474
/** Draft message for the report action */
75-
draftMessage?: OnyxEntry<string & OnyxTypes.ReportActionsDrafts> | undefined;
75+
draftMessage?: string;
7676

7777
/** Emoji reactions for the report action */
7878
emojiReactions?: OnyxEntry<OnyxTypes.ReportActionReactions>;

src/pages/home/report/ReportActionsList.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ function ReportActionsList({
587587
({item: reportAction, index}: ListRenderItemInfo<OnyxTypes.ReportAction>) => {
588588
const originalReportID = getOriginalReportID(report.reportID, reportAction);
589589
const reportDraftMessages = draftMessage?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${originalReportID}`];
590+
const matchingDraftMessage = reportDraftMessages?.[reportAction.reportActionID];
591+
const matchingDraftMessageString = typeof matchingDraftMessage === 'string' ? matchingDraftMessage : matchingDraftMessage?.message;
592+
590593
const actionEmojiReactions = emojiReactions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportAction.reportActionID}`];
591594
const transactionID = isMoneyRequestAction(reportAction) && getOriginalMessage(reportAction)?.IOUTransactionID;
592595
const transaction = transactionID ? transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] : undefined;
@@ -618,7 +621,7 @@ function ReportActionsList({
618621
userWallet={userWallet}
619622
isUserValidated={isUserValidated}
620623
personalDetails={personalDetailsList}
621-
draftMessage={reportDraftMessages as OnyxEntry<string & OnyxTypes.ReportActionsDrafts>}
624+
draftMessage={matchingDraftMessageString}
622625
emojiReactions={actionEmojiReactions}
623626
linkedTransactionRouteError={actionLinkedTransactionRouteError}
624627
userBillingFundID={userBillingFundID}

src/pages/home/report/ReportActionsListItemRenderer.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
33
import {getOriginalMessage, isSentMoneyReportAction, isTransactionThread} from '@libs/ReportActionsUtils';
44
import {isChatThread, isInvoiceRoom, isPolicyExpenseChat} from '@libs/ReportUtils';
55
import CONST from '@src/CONST';
6-
import type {PersonalDetailsList, Policy, Report, ReportAction, ReportActionReactions, ReportActionsDrafts, Transaction, UserWallet} from '@src/types/onyx';
6+
import type {PersonalDetailsList, Policy, Report, ReportAction, ReportActionReactions, Transaction, UserWallet} from '@src/types/onyx';
77
import type {Errors} from '@src/types/onyx/OnyxCommon';
88
import ReportActionItem from './ReportActionItem';
99
import ReportActionItemParentAction from './ReportActionItemParentAction';
@@ -64,25 +64,25 @@ type ReportActionsListItemRendererProps = {
6464
shouldUseThreadDividerLine?: boolean;
6565

6666
/** Draft messages for the report */
67-
draftMessage?: OnyxEntry<string & ReportActionsDrafts> | undefined;
67+
draftMessage?: string;
6868

6969
/** Emoji reactions for the report action */
7070
emojiReactions?: OnyxEntry<ReportActionReactions>;
7171

7272
/** User wallet */
73-
userWallet?: OnyxEntry<UserWallet>;
73+
userWallet: OnyxEntry<UserWallet>;
7474

7575
/** Linked transaction route error */
7676
linkedTransactionRouteError?: OnyxEntry<Errors>;
7777

7878
/** Whether the user is validated */
79-
isUserValidated?: boolean | undefined;
79+
isUserValidated: boolean | undefined;
8080

8181
/** Personal details list */
82-
personalDetails?: OnyxEntry<PersonalDetailsList>;
82+
personalDetails: OnyxEntry<PersonalDetailsList>;
8383

8484
/** User billing fund ID */
85-
userBillingFundID?: number | undefined;
85+
userBillingFundID: number | undefined;
8686
};
8787

8888
function ReportActionsListItemRenderer({

0 commit comments

Comments
 (0)