Skip to content

Commit 735721f

Browse files
authored
Merge pull request Expensify#79736 from tsa321/fixSearchActionFilter
Support displaying a pending state in the report status for To-Do search results when an action is pending
2 parents e5de046 + 8bd70a3 commit 735721f

8 files changed

Lines changed: 42 additions & 8 deletions

File tree

src/components/ReportSearchHeader/index.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ function ReportSearchHeader({report, style, transactions, avatarBorderColor}: Re
99
const styles = useThemeStyles();
1010
const {isLargeScreenWidth} = useResponsiveLayout();
1111

12+
const statusContainerStyle = useMemo(() => {
13+
return [isLargeScreenWidth ? styles.mt1 : styles.mt0Half, report?.shouldShowStatusAsPending && styles.offlineFeedbackPending];
14+
}, [isLargeScreenWidth, styles.mt1, styles.mt0Half, report?.shouldShowStatusAsPending, styles.offlineFeedbackPending]);
15+
1216
const middleContent = useMemo(() => {
1317
return (
1418
<AvatarWithDisplayName
@@ -21,10 +25,21 @@ function ReportSearchHeader({report, style, transactions, avatarBorderColor}: Re
2125
avatarBorderColor={avatarBorderColor}
2226
customDisplayNameStyle={styles.fontWeightNormal}
2327
parentNavigationSubtitleTextStyles={[styles.textLineHeightNormal, styles.minHeight4, styles.mt1, !isLargeScreenWidth && styles.textMicro]}
24-
parentNavigationStatusContainerStyles={isLargeScreenWidth ? styles.mt1 : styles.mt0Half}
28+
parentNavigationStatusContainerStyles={statusContainerStyle}
2529
/>
2630
);
27-
}, [report, transactions, avatarBorderColor, styles.fontWeightNormal, styles.textLineHeightNormal, styles.minHeight4, styles.mt1, isLargeScreenWidth, styles.textMicro, styles.mt0Half]);
31+
}, [
32+
report,
33+
transactions,
34+
avatarBorderColor,
35+
styles.fontWeightNormal,
36+
styles.textLineHeightNormal,
37+
styles.minHeight4,
38+
styles.mt1,
39+
isLargeScreenWidth,
40+
styles.textMicro,
41+
statusContainerStyle,
42+
]);
2843

2944
return (
3045
<View

src/components/ReportSearchHeader/types.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import type {ColorValue, StyleProp, ViewStyle} from 'react-native';
2-
import type {OnyxEntry} from 'react-native-onyx';
3-
import type {TransactionListItemType} from '@components/SelectionListWithSections/types';
4-
import type {Report} from '@src/types/onyx';
2+
import type {ExpenseReportListItemType, TransactionListItemType} from '@components/SelectionListWithSections/types';
53

64
type ReportSearchHeaderProps = {
75
/** Report, if we're showing the details for one and using AvatarWithDisplay */
8-
report?: OnyxEntry<Report>;
6+
report?: ExpenseReportListItemType;
97

108
/** Additional styles to add to the component */
119
style?: StyleProp<ViewStyle>;

src/components/Search/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,13 @@ function Search({
429429
queryJSON,
430430
isActionLoadingSet,
431431
cardFeeds,
432+
isOffline,
432433
allTransactionViolations: violations,
433434
});
434435
return [filteredData1, filteredData1.length, allLength];
435436
}, [
436437
searchKey,
438+
isOffline,
437439
exportReportActions,
438440
validGroupBy,
439441
isDataLoaded,

src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ function ExpenseReportListItemRow({
113113
<StatusCell
114114
stateNum={item.stateNum}
115115
statusNum={item.statusNum}
116+
isPending={item.shouldShowStatusAsPending}
116117
/>
117118
</View>
118119
),

src/components/SelectionListWithSections/Search/StatusCell.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ type StatusCellProps = {
1212

1313
/** The statusNum of the report */
1414
statusNum?: number;
15+
16+
/** Whether the report's state/status is pending */
17+
isPending?: boolean;
1518
};
1619

17-
function StatusCell({stateNum, statusNum}: StatusCellProps) {
20+
function StatusCell({stateNum, statusNum, isPending}: StatusCellProps) {
1821
const styles = useThemeStyles();
1922
const theme = useTheme();
2023
const {translate} = useLocalize();
@@ -41,7 +44,7 @@ function StatusCell({stateNum, statusNum}: StatusCellProps) {
4144
}
4245

4346
return (
44-
<View style={[styles.w100, styles.justifyContentCenter]}>
47+
<View style={[styles.w100, styles.justifyContentCenter, isPending && styles.offlineFeedbackPending]}>
4548
<View style={[styles.reportStatusContainer, backgroundColorStyle]}>
4649
<Text style={[styles.reportStatusText, textColorStyle]}>{statusText}</Text>
4750
</View>

src/components/SelectionListWithSections/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ type TransactionReportGroupListItemType = TransactionGroupListItemType & {groupe
449449
/** The date the report was exported */
450450
exported?: string;
451451

452+
/** Whether the status field should be shown in a pending state */
453+
shouldShowStatusAsPending?: boolean;
454+
452455
/**
453456
* Whether we should show the report year.
454457
* This is true if at least one report in the dataset was created in past years

src/libs/SearchUIUtils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ type GetReportSectionsParams = {
181181
translate: LocalizedTranslate;
182182
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
183183
isActionLoadingSet: ReadonlySet<string> | undefined;
184+
isOffline: boolean | undefined;
184185
allTransactionViolations: OnyxCollection<OnyxTypes.TransactionViolation[]>;
185186
bankAccountList: OnyxEntry<OnyxTypes.BankAccountList>;
186187
reportActions?: Record<string, OnyxTypes.ReportAction[]>;
@@ -426,6 +427,7 @@ type GetSectionsParams = {
426427
archivedReportsIDList?: ArchivedReportsIDSet;
427428
queryJSON?: SearchQueryJSON;
428429
isActionLoadingSet?: ReadonlySet<string>;
430+
isOffline?: boolean;
429431
cardFeeds?: OnyxCollection<OnyxTypes.CardFeeds>;
430432
allTransactionViolations?: OnyxCollection<OnyxTypes.TransactionViolation[]>;
431433
};
@@ -1872,6 +1874,7 @@ function getReportSections({
18721874
currentAccountID,
18731875
currentUserEmail,
18741876
translate,
1877+
isOffline,
18751878
formatPhoneNumber,
18761879
isActionLoadingSet,
18771880
allTransactionViolations,
@@ -1963,6 +1966,8 @@ function getReportSections({
19631966
const policyFromKey = getPolicyFromKey(data, reportItem);
19641967
const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${reportItem?.policyID ?? String(CONST.DEFAULT_NUMBER_ID)}`] ?? policyFromKey;
19651968

1969+
const shouldShowStatusAsPending = !!isOffline && reportItem?.pendingFields?.nextStep === CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE;
1970+
19661971
const hasAnyViolationsForReport = hasAnyViolations(
19671972
reportItem.reportID,
19681973
allTransactionViolations ?? allViolations,
@@ -1996,6 +2001,7 @@ function getReportSections({
19962001
formattedTo,
19972002
formattedStatus,
19982003
transactions,
2004+
shouldShowStatusAsPending,
19992005
...(reportPendingAction ? {pendingAction: reportPendingAction} : {}),
20002006
shouldShowYear: shouldShowYearCreatedReport,
20012007
shouldShowYearSubmitted: shouldShowYearSubmittedReport,
@@ -2462,6 +2468,7 @@ function getSections({
24622468
archivedReportsIDList,
24632469
queryJSON,
24642470
isActionLoadingSet,
2471+
isOffline,
24652472
cardFeeds,
24662473
allTransactionViolations,
24672474
}: GetSectionsParams) {
@@ -2480,6 +2487,7 @@ function getSections({
24802487
currentAccountID,
24812488
currentUserEmail,
24822489
translate,
2490+
isOffline,
24832491
formatPhoneNumber,
24842492
isActionLoadingSet,
24852493
allTransactionViolations,

tests/unit/Search/SearchUIUtilsTest.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ const transactionReportGroupListItems = [
10721072
},
10731073
hasVisibleViolations: false,
10741074
isOneTransactionReport: true,
1075+
shouldShowStatusAsPending: false,
10751076
isWaitingOnBankAccount: false,
10761077
keyForList: '123456789',
10771078
managerID: 18439984,
@@ -1173,6 +1174,7 @@ const transactionReportGroupListItems = [
11731174
},
11741175
hasVisibleViolations: true,
11751176
isOneTransactionReport: true,
1177+
shouldShowStatusAsPending: false,
11761178
isWaitingOnBankAccount: false,
11771179
keyForList: '11111',
11781180
managerID: 18439984,
@@ -1281,6 +1283,7 @@ const transactionReportGroupListItems = [
12811283
formattedTo: 'Approver',
12821284
hasVisibleViolations: false,
12831285
isOneTransactionReport: false,
1286+
shouldShowStatusAsPending: false,
12841287
isOwnPolicyExpenseChat: false,
12851288
isWaitingOnBankAccount: false,
12861289
managerID: 1111111,
@@ -1461,6 +1464,7 @@ const transactionReportGroupListItems = [
14611464
},
14621465
hasVisibleViolations: false,
14631466
isOneTransactionReport: true,
1467+
shouldShowStatusAsPending: false,
14641468
isWaitingOnBankAccount: false,
14651469
keyForList: reportID5,
14661470
managerID: 18439984,

0 commit comments

Comments
 (0)