-
Notifications
You must be signed in to change notification settings - Fork 4k
Deprecate SearchTransaction > moneyRequestReportActionID #75648
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
Changes from all commits
76b435d
9a0fd07
353cb27
d8fd38a
0cad262
0833093
e3ff6f3
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 |
|---|---|---|
|
|
@@ -71,8 +71,8 @@ function TransactionListItem<TItem extends ListItem>({ | |
| const [transactionThreadReport] = originalUseOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionItem?.reportAction?.childReportID}`, {canBeMissing: true}); | ||
| const [transaction] = originalUseOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionItem.transactionID}`, {canBeMissing: true}); | ||
| const parentReportActionSelector = useCallback( | ||
| (reportActions: OnyxEntry<ReportActions>): OnyxEntry<ReportAction> => reportActions?.[`${transactionItem?.moneyRequestReportActionID}`], | ||
| [transactionItem?.moneyRequestReportActionID], | ||
| (reportActions: OnyxEntry<ReportActions>): OnyxEntry<ReportAction> => reportActions?.[`${transactionItem?.reportAction?.reportActionID}`], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential runtime error: When Suggested fix: Add a null check before the template literal: (reportActions: OnyxEntry<ReportActions>): OnyxEntry<ReportAction> => {
const reportActionID = transactionItem?.reportAction?.reportActionID;
return reportActionID ? reportActions?.[reportActionID] : undefined;
},Or use a more concise approach: (reportActions: OnyxEntry<ReportActions>): OnyxEntry<ReportAction> =>
transactionItem?.reportAction?.reportActionID
? reportActions?.[transactionItem.reportAction.reportActionID]
: undefined, |
||
| [transactionItem?.reportAction?.reportActionID], | ||
| ); | ||
| const [parentReportAction] = originalUseOnyx( | ||
| `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(transactionItem.reportID)}`, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1105,7 +1105,8 @@ function getTotalFormattedAmount(selectedReports: SelectedReports[], selectedTra | |
| * Note: we don't create anything new, we just optimistically generate the data that we know will be returned by API. | ||
| */ | ||
| function setOptimisticDataForTransactionThreadPreview(item: TransactionListItemType, transactionPreviewData: TransactionPreviewData, IOUTransactionID?: string) { | ||
| const {moneyRequestReportActionID, reportID, report, amount, currency, transactionID, created, policyID} = item; | ||
| const {reportID, report, amount, currency, transactionID, created, policyID} = item; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type safety issue: The destructuring attempts to extract Suggested fix: Remove the destructuring of const {reportID, report, amount, currency, transactionID, created, policyID} = item;
const moneyRequestReportActionID = item.reportAction?.reportActionID;This makes the code clearer and ensures the correct value is used. |
||
| const moneyRequestReportActionID = item?.reportAction?.reportActionID; | ||
| const {hasParentReport, hasParentReportAction, hasTransaction, hasTransactionThreadReport} = transactionPreviewData; | ||
| const onyxUpdates: OnyxUpdate[] = []; | ||
|
|
||
|
|
||
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.
Potential runtime error: When
oneTransactionItem?.reportActionisundefined, the expressiononeTransactionItem?.reportAction?.reportActionIDevaluates toundefined. Inside the template literal\${undefined}`, this becomes the **string**"undefined", causing the selector to look upreportActions["undefined"]instead of returningundefined`.Suggested fix: Add a null check before the template literal:
Or use a more concise approach:
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.
This is similar to what we currently have. That being said, I like the suggestion because it's more explicit. @DylanDylann let's implement it this way
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.
@DylanDylann we can use the suggested approach to avoid
reportActions["undefined"]. Also @luacmartins agrees to it.