Skip to content
9 changes: 5 additions & 4 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useMemo, useRef, useState} from 'react';
// eslint-disable-next-line no-restricted-imports
import type {GestureResponderEvent, Text as RNText} from 'react-native';
import type {GestureResponderEvent, ImageStyle, Text as RNText, ViewStyle} from 'react-native';
import {Linking, View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import type {OnyxCollection} from 'react-native-onyx';
Expand Down Expand Up @@ -144,11 +144,11 @@ function EmptySearchView({type, hasResults}: EmptySearchViewProps) {
case CONST.SEARCH.DATA_TYPES.TRIP:
return {
headerMedia: LottieAnimations.TripsEmptyState,
headerContentStyles: [StyleUtils.getWidthAndHeightStyle(375, 240), StyleUtils.getBackgroundColorStyle(theme.travelBG)],
headerContentStyles: [styles.emptyStateFolderWebStyles, StyleUtils.getBackgroundColorStyle(theme.travelBG)],
title: translate('travel.title'),
titleStyles: {...styles.textAlignLeft},
children: tripViewChildren,
lottieWebViewStyles: {backgroundColor: theme.travelBG, ...styles.emptyStateFolderWebStyles},
lottieWebViewStyles: {backgroundColor: theme.travelBG, ...styles.emptyStateFolderWebStyles, ...styles.tripEmptyStateLottieWebView},
};
case CONST.SEARCH.DATA_TYPES.EXPENSE:
if (!hasResults) {
Expand Down Expand Up @@ -247,6 +247,7 @@ function EmptySearchView({type, hasResults}: EmptySearchViewProps) {
translate,
styles.textAlignLeft,
styles.emptyStateFolderWebStyles,
styles.tripEmptyStateLottieWebView,
tripViewChildren,
hasSeenTour,
navatticURL,
Expand All @@ -272,7 +273,7 @@ function EmptySearchView({type, hasResults}: EmptySearchViewProps) {
titleStyles={content.titleStyles}
subtitle={content.subtitle}
buttons={content.buttons}
headerContentStyles={[styles.h100, styles.w100, ...content.headerContentStyles]}
headerContentStyles={[styles.h100, styles.w100, ...content.headerContentStyles] as Array<ViewStyle & ImageStyle>}

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.

Please revert this change , I don't think it's needed here.

@nabi-ebrahimi nabi-ebrahimi May 15, 2025 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I need to either update the type of the headerContentStyles prop or leave it as is, since removing it leads to a type error.

Currently, its type is ViewStyle & ImageStyle in the EmptyStateComponent, so we’d also need to update the types in EmptyStateComponent accordingly.

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.

If the styling is consistent across other headerContentStyles, why is CONST.SEARCH.DATA_TYPES.TRIP the only one throwing a type error?

@nabi-ebrahimi nabi-ebrahimi May 16, 2025 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Other cases in the switch include !hasResults, which hinders TypeScript's ability to infer types accurately.

For example, returning this value in the first case causes type errors that are handled correctly in the default case.

  return {
                    headerMedia: LottieAnimations.GenericEmptyState,
                    title: translate('search.searchResults.emptyResults.title'),
                    subtitle: translate('search.searchResults.emptyResults.subtitle'),
                    headerContentStyles: [styles.emptyStateFolderWebStyles, StyleUtils.getBackgroundColorStyle(theme.emptyFolderBG)],
                    lottieWebViewStyles: {backgroundColor: theme.emptyFolderBG, ...styles.emptyStateFolderWebStyles},
                };

lottieWebViewStyles={content.lottieWebViewStyles}
>
{content.children}
Expand Down
5 changes: 5 additions & 0 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5628,6 +5628,11 @@ const styles = (theme: ThemeColors) =>
...display.dFlex,
},

tripEmptyStateLottieWebView: {
width: 335,
height: 220,
},

workflowApprovalVerticalLine: {
height: 16,
width: 1,
Expand Down