Skip to content

Commit b1f8df9

Browse files
committed
fix PR comments
1 parent 9a1167d commit b1f8df9

3 files changed

Lines changed: 4 additions & 9 deletions

File tree

src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,11 @@ function MoneyRequestReportPreviewContent({
114114
isInvoice,
115115
shouldShowBorder = false,
116116
onPress,
117-
chatReportMetadata,
118117
}: MoneyRequestReportPreviewContentProps) {
118+
const [chatReportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${chatReportID}`, {canBeMissing: true, allowStaleData: true});
119119
const shouldShowLoading = !chatReportMetadata?.hasOnceLoadedReportActions && transactions.length === 0;
120-
// hasOnceLoadedReportActions is set as true one render before transactions are hydrated, to avoid showing empty state we need to defer loading state, so that it waits one more render for transactions
120+
// `hasOnceLoadedReportActions` becomes true before transactions populate fully,
121+
// so we defer the loading state update to ensure transactions are loaded
121122
const shouldShowLoadingDeferred = useDeferredValue(shouldShowLoading);
122123
const lastTransaction = transactions?.at(0);
123124
const shouldShowEmptyPlaceholder = transactions.length === 0;

src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, {useCallback, useMemo, useState} from 'react';
22
import type {LayoutChangeEvent, ListRenderItem} from 'react-native';
33
import {usePersonalDetails} from '@components/OnyxProvider';
44
import TransactionPreview from '@components/ReportActionItem/TransactionPreview';
5-
import useOnyx from '@hooks/useOnyx';
65
import usePolicy from '@hooks/usePolicy';
76
import useReportWithTransactionsAndViolations from '@hooks/useReportWithTransactionsAndViolations';
87
import useResponsiveLayout from '@hooks/useResponsiveLayout';
@@ -59,7 +58,6 @@ function MoneyRequestReportPreview({
5958
() => StyleUtils.getMoneyRequestReportPreviewStyle(shouldUseNarrowLayout, transactions.length, currentWidth, currentWrapperWidth),
6059
[StyleUtils, currentWidth, currentWrapperWidth, shouldUseNarrowLayout, transactions.length],
6160
);
62-
const [chatReportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${chatReportID}`, {canBeMissing: true, allowStaleData: true});
6361
const shouldShowPayerAndReceiver = useMemo(() => {
6462
if (!isIOUReport(iouReport) && action.childType !== CONST.REPORT.TYPE.IOU) {
6563
return false;
@@ -109,7 +107,6 @@ function MoneyRequestReportPreview({
109107
iouReport={iouReport}
110108
chatReport={chatReport}
111109
action={action}
112-
chatReportMetadata={chatReportMetadata}
113110
containerStyles={[reportPreviewStyles.componentStyle]}
114111
contextMenuAnchor={contextMenuAnchor}
115112
isHovered={isHovered}

src/components/ReportActionItem/MoneyRequestReportPreview/types.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {LayoutChangeEvent, ListRenderItem, StyleProp, ViewStyle} from 'reac
22
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
33
import type {TransactionPreviewStyleType} from '@components/ReportActionItem/TransactionPreview/types';
44
import type {ContextMenuAnchor} from '@pages/home/report/ContextMenu/ReportActionContextMenu';
5-
import type {PersonalDetails, Policy, Report, ReportAction, ReportMetadata, Transaction, TransactionViolation, TransactionViolations} from '@src/types/onyx';
5+
import type {PersonalDetails, Policy, Report, ReportAction, Transaction, TransactionViolation, TransactionViolations} from '@src/types/onyx';
66

77
type TransactionPreviewCarouselStyle = {
88
[key in keyof TransactionPreviewStyleType]: number;
@@ -102,9 +102,6 @@ type MoneyRequestReportPreviewContentProps = MoneyRequestReportPreviewContentOny
102102

103103
/** Callback called when the whole preview is pressed */
104104
onPress: () => void;
105-
106-
/** Report metadata */
107-
chatReportMetadata: OnyxEntry<ReportMetadata>;
108105
};
109106

110107
export type {MoneyRequestReportPreviewContentProps, MoneyRequestReportPreviewProps, MoneyRequestReportPreviewStyleType};

0 commit comments

Comments
 (0)