-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(2/2) Add support for all reportAction types in ChatListItem - use PureReportActionItem in ChatListItem #54228
base: main
Are you sure you want to change the base?
Changes from all commits
eea0421
e0f2a61
5808732
639b413
7dc43b4
0d0c33a
6247a8a
4e7018f
2e96dbe
4f5207a
2c0ee75
8d64fba
273f76c
ee5de13
45d68c5
5046a48
faaa140
c4145e6
220b657
35f99be
d7d9818
f55cff9
45b406f
299992e
8d74ba2
340bee5
e7d801c
b189a00
760ca69
2705f78
135c677
6f59803
974d5b8
055a263
0a1044a
a361dcb
ba54e4e
0fc3a45
e51cf56
6997752
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,22 +2,23 @@ | |
import {useOnyx} from 'react-native-onyx'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import {useBlockedFromConcierge, usePersonalDetails} from '@components/OnyxProvider'; | ||
import usePolicy from '@hooks/usePolicy'; | ||
import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage'; | ||
import * as ReportActionsUtils from '@libs/ReportActionsUtils'; | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
import * as Report from '@userActions/Report'; | ||
import * as ReportActions from '@userActions/ReportActions'; | ||
import * as Transaction from '@userActions/Transaction'; | ||
import type CONST from '@src/CONST'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {ReportAction} from '@src/types/onyx'; | ||
import type {PureReportActionItemProps} from './PureReportActionItem'; | ||
import PureReportActionItem from './PureReportActionItem'; | ||
|
||
function ReportActionItem({action, report, ...props}: PureReportActionItemProps) { | ||
function ReportActionItem({action, report, parentReportActionForTransactionThread, ...props}: PureReportActionItemProps) { | ||
const reportID = report?.reportID ?? ''; | ||
Check failure on line 19 in src/pages/home/report/ReportActionItem.tsx GitHub Actions / Changed files ESLint check
|
||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
const originalReportID = useMemo(() => ReportUtils.getOriginalReportID(reportID, action) || '-1', [reportID, action]); | ||
Check failure on line 21 in src/pages/home/report/ReportActionItem.tsx GitHub Actions / Changed files ESLint check
|
||
const [draftMessage] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${originalReportID}`, { | ||
selector: (draftMessagesForReport) => { | ||
const matchingDraftMessage = draftMessagesForReport?.[action.reportActionID]; | ||
|
@@ -28,21 +29,30 @@ | |
const [emojiReactions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${action.reportActionID}`); | ||
const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET); | ||
const [linkedTransactionRouteError] = useOnyx( | ||
`${ONYXKEYS.COLLECTION.TRANSACTION}${ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID ?? -1 : -1}`, | ||
Check failure on line 32 in src/pages/home/report/ReportActionItem.tsx GitHub Actions / Changed files ESLint check
|
||
{selector: (transaction) => transaction?.errorFields?.route ?? null}, | ||
); | ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- This is needed to prevent the app from crashing when the app is using imported state. | ||
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || '-1'}`); | ||
Check failure on line 36 in src/pages/home/report/ReportActionItem.tsx GitHub Actions / Changed files ESLint check
|
||
|
||
const [isUserValidated] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.validated}); | ||
// 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. | ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || -1}`); | ||
Check failure on line 41 in src/pages/home/report/ReportActionItem.tsx GitHub Actions / Changed files ESLint check
|
||
const personalDetails = usePersonalDetails(); | ||
const blockedFromConcierge = useBlockedFromConcierge(); | ||
const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID); | ||
const linkedReport = ReportUtils.isChatThread(report) ? parentReport : report; | ||
const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, linkedReport?.reportID ?? '-1', action); | ||
Check failure on line 46 in src/pages/home/report/ReportActionItem.tsx GitHub Actions / Changed files ESLint check
|
||
const policy = usePolicy(report?.policyID); | ||
const [invoiceReceiverPolicy] = useOnyx( | ||
`${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : CONST.DEFAULT_NUMBER_ID}`, | ||
); | ||
const IOUTransactionID = ReportActionsUtils.isMoneyRequestAction(parentReportActionForTransactionThread) | ||
? ReportActionsUtils.getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID | ||
Check failure on line 52 in src/pages/home/report/ReportActionItem.tsx GitHub Actions / ESLint check
|
||
: '-1'; | ||
Check failure on line 53 in src/pages/home/report/ReportActionItem.tsx GitHub Actions / ESLint check
Check failure on line 53 in src/pages/home/report/ReportActionItem.tsx GitHub Actions / Changed files ESLint check
Check failure on line 53 in src/pages/home/report/ReportActionItem.tsx GitHub Actions / Changed files ESLint check
|
||
|
||
const [IOUTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${IOUTransactionID ?? '-1'}`); | ||
|
||
return ( | ||
<PureReportActionItem | ||
|
@@ -81,6 +91,9 @@ | |
dismissTrackExpenseActionableWhisper={Report.dismissTrackExpenseActionableWhisper} | ||
userBillingFundID={userBillingFundID} | ||
reportAutomaticallyForwardedMessage={ReportUtils.getReportAutomaticallyForwardedMessage(action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.FORWARDED>, reportID)} | ||
policy={policy} | ||
invoiceReceiverPolicy={invoiceReceiverPolicy} | ||
IOUTransaction={IOUTransaction} | ||
/> | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't comment on the line, but
ReportPreview
in line 736 is still directly connected to Onyx, which means it doesn't show correct report data, e.g.Screen.Recording.2024-12-31.at.3.21.29.PM.mov