Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import type {ReactNode} from 'react';
import {View} from 'react-native';
import * as Expensicons from '@components/Icon/Expensicons';
import ImageSVG from '@components/ImageSVG';
Expand All @@ -9,7 +8,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';

function EmptyMoneyRequestReportPreview({emptyReportPreviewAction}: {emptyReportPreviewAction: ReactNode | undefined}) {
function EmptyMoneyRequestReportPreview() {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
Expand All @@ -18,7 +17,7 @@ function EmptyMoneyRequestReportPreview({emptyReportPreviewAction}: {emptyReport
return (
<View style={[styles.alignItemsCenter, styles.highlightBG, styles.ml0, styles.mr0, styles.gap4, styles.reportContainerBorderRadius]}>
<View style={[styles.emptyStateMoneyRequestPreviewReport, styles.justifyContentCenter, styles.alignItemsCenter]}>
<View style={[styles.m1, styles.justifyContentCenter, styles.alignItemsCenter, styles.gap4]}>
<View style={[{width: shouldUseNarrowLayout ? '100%' : 303}, styles.m1, styles.justifyContentCenter, styles.alignItemsCenter, styles.gap4]}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use const for the width here?

@jakubkalinski0 jakubkalinski0 Jul 29, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, that part I used was from the removed button on the EmptyMoneyRequestReportPreview, as it seemed to define the width for the entire component. I patched it up quickly as we wanted to fix it asap, but now that we have more breathing room, I will gladly clean it up and handle the bug in the follow-up.

<ImageSVG
fill={theme.border}
height={64}
Expand All @@ -28,7 +27,6 @@ function EmptyMoneyRequestReportPreview({emptyReportPreviewAction}: {emptyReport
<Text style={[styles.textAlignCenter, styles.textSupporting, styles.fontSizeLabel]}>{translate('search.moneyRequestReport.emptyStateTitle')}</Text>
</View>
</View>
<View style={[{width: shouldUseNarrowLayout ? '100%' : 303, height: 40}]}>{!!emptyReportPreviewAction && emptyReportPreviewAction}</View>
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ function MoneyRequestReportPreviewContent({
// so we defer the loading state update to ensure transactions are loaded
const shouldShowLoadingDeferred = useDeferredValue(shouldShowLoading);
const lastTransaction = transactions?.at(0);
const shouldShowEmptyPlaceholder = transactions.length === 0;
const shouldShowSkeleton = shouldShowLoading && transactions.length === 0;
const shouldShowEmptyPlaceholder = transactions.length === 0 && !shouldShowLoading;
const showStatusAndSkeleton = !shouldShowEmptyPlaceholder;
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
Expand Down Expand Up @@ -636,13 +638,15 @@ function MoneyRequestReportPreviewContent({
</Text>
</Animated.View>
</View>
{shouldShowEmptyPlaceholder ? (
{showStatusAndSkeleton && shouldShowSkeleton ? (
<MoneyReportHeaderStatusBarSkeleton />
) : (
<View style={[styles.flexRow, styles.justifyContentStart, styles.alignItemsCenter]}>
{isIconNeeded && <View style={[styles.alignItemsCenter, styles.lh16, styles.mr1]}>{approvedOrSettledIcon}</View>}
<Text style={[styles.textLabelSupporting, styles.lh16]}>{`${reportStatus} ${CONST.DOT_SEPARATOR} ${expenseCount}`}</Text>
</View>
!shouldShowEmptyPlaceholder && (
<View style={[styles.flexRow, styles.justifyContentStart, styles.alignItemsCenter]}>
{isIconNeeded && <View style={[styles.alignItemsCenter, styles.lh16, styles.mr1]}>{approvedOrSettledIcon}</View>}
<Text style={[styles.textLabelSupporting, styles.lh16]}>{`${reportStatus} ${CONST.DOT_SEPARATOR} ${expenseCount}`}</Text>
</View>
)
)}
</View>
{!shouldUseNarrowLayout && transactions.length > 2 && reportPreviewStyles.expenseCountVisible && (
Expand Down Expand Up @@ -727,7 +731,7 @@ function MoneyRequestReportPreviewContent({
ListFooterComponent={<View style={styles.pl2} />}
ListHeaderComponent={<View style={styles.pr2} />}
/>
{shouldShowEmptyPlaceholder && <EmptyMoneyRequestReportPreview emptyReportPreviewAction={reportPreviewActions[reportPreviewAction]} />}
{shouldShowEmptyPlaceholder && <EmptyMoneyRequestReportPreview />}
</View>
)}
<View style={[styles.expenseAndReportPreviewTextContainer]}>
Expand Down
Loading