Skip to content

Commit 4cbebe1

Browse files
committed
add offline check
Signed-off-by: Tsaqif <tsaiinkwa@yahoo.com>
1 parent ffaa8be commit 4cbebe1

6 files changed

Lines changed: 18 additions & 11 deletions

File tree

src/components/ReportSearchHeader/index.tsx

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

1212
const statusContainerStyle = useMemo(() => {
13-
return [isLargeScreenWidth ? styles.mt1 : styles.mt0Half, report?.isReportStatePending && styles.offlineFeedbackPending];
14-
}, [isLargeScreenWidth, styles.mt1, styles.mt0Half, report?.isReportStatePending, styles.offlineFeedbackPending]);
13+
return [isLargeScreenWidth ? styles.mt1 : styles.mt0Half, report?.shouldShowStatusAsPending && styles.offlineFeedbackPending];
14+
}, [isLargeScreenWidth, styles.mt1, styles.mt0Half, report?.shouldShowStatusAsPending, styles.offlineFeedbackPending]);
1515

1616
const middleContent = useMemo(() => {
1717
return (

src/components/Search/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,13 @@ function Search({
420420
queryJSON,
421421
isActionLoadingSet,
422422
cardFeeds,
423+
isOffline,
423424
allTransactionViolations: violations,
424425
});
425426
return [filteredData1, filteredData1.length, allLength];
426427
}, [
427428
searchKey,
429+
isOffline,
428430
exportReportActions,
429431
validGroupBy,
430432
isDataLoaded,

src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function ExpenseReportListItemRow({
113113
<StatusCell
114114
stateNum={item.stateNum}
115115
statusNum={item.statusNum}
116-
isPending={item.isReportStatePending}
116+
isPending={item.shouldShowStatusAsPending}
117117
/>
118118
</View>
119119
),

src/components/SelectionListWithSections/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ type TransactionReportGroupListItemType = TransactionGroupListItemType & {groupe
448448
/** The date the report was exported */
449449
exported?: string;
450450

451-
/** Whether the report's state/status is pending */
452-
isReportStatePending?: boolean;
451+
/** Whether the status field should be shown in a pending state */
452+
shouldShowStatusAsPending?: boolean;
453453

454454
/**
455455
* Whether we should show the report year.

src/libs/SearchUIUtils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ type GetReportSectionsParams = {
165165
translate: LocalizedTranslate;
166166
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
167167
isActionLoadingSet: ReadonlySet<string> | undefined;
168+
isOffline: boolean | undefined;
168169
allTransactionViolations: OnyxCollection<OnyxTypes.TransactionViolation[]>;
169170
bankAccountList: OnyxEntry<OnyxTypes.BankAccountList>;
170171
reportActions?: Record<string, OnyxTypes.ReportAction[]>;
@@ -405,6 +406,7 @@ type GetSectionsParams = {
405406
archivedReportsIDList?: ArchivedReportsIDSet;
406407
queryJSON?: SearchQueryJSON;
407408
isActionLoadingSet?: ReadonlySet<string>;
409+
isOffline?: boolean;
408410
cardFeeds?: OnyxCollection<OnyxTypes.CardFeeds>;
409411
allTransactionViolations?: OnyxCollection<OnyxTypes.TransactionViolation[]>;
410412
};
@@ -1820,6 +1822,7 @@ function getReportSections({
18201822
currentAccountID,
18211823
currentUserEmail,
18221824
translate,
1825+
isOffline,
18231826
formatPhoneNumber,
18241827
isActionLoadingSet,
18251828
allTransactionViolations,
@@ -1911,7 +1914,7 @@ function getReportSections({
19111914
const policyFromKey = getPolicyFromKey(data, reportItem);
19121915
const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${reportItem?.policyID ?? String(CONST.DEFAULT_NUMBER_ID)}`] ?? policyFromKey;
19131916

1914-
const isReportStatePending = reportItem?.pendingFields?.nextStep === CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE;
1917+
const shouldShowStatusAsPending = isOffline && reportItem?.pendingFields?.nextStep === CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE;
19151918

19161919
const hasAnyViolationsForReport = hasAnyViolations(
19171920
reportItem.reportID,
@@ -1945,8 +1948,8 @@ function getReportSections({
19451948
formattedFrom,
19461949
formattedTo,
19471950
formattedStatus,
1948-
isReportStatePending,
19491951
transactions,
1952+
shouldShowStatusAsPending,
19501953
...(reportPendingAction ? {pendingAction: reportPendingAction} : {}),
19511954
shouldShowYear: shouldShowYearCreatedReport,
19521955
shouldShowYearSubmitted: shouldShowYearSubmittedReport,
@@ -2355,6 +2358,7 @@ function getSections({
23552358
archivedReportsIDList,
23562359
queryJSON,
23572360
isActionLoadingSet,
2361+
isOffline,
23582362
cardFeeds,
23592363
allTransactionViolations,
23602364
}: GetSectionsParams) {
@@ -2373,6 +2377,7 @@ function getSections({
23732377
currentAccountID,
23742378
currentUserEmail,
23752379
translate,
2380+
isOffline,
23762381
formatPhoneNumber,
23772382
isActionLoadingSet,
23782383
allTransactionViolations,

tests/unit/Search/SearchUIUtilsTest.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ const transactionReportGroupListItems = [
10691069
},
10701070
hasVisibleViolations: false,
10711071
isOneTransactionReport: true,
1072-
isReportStatePending: false,
1072+
shouldShowStatusAsPending: false,
10731073
isWaitingOnBankAccount: false,
10741074
keyForList: '123456789',
10751075
managerID: 18439984,
@@ -1171,7 +1171,7 @@ const transactionReportGroupListItems = [
11711171
},
11721172
hasVisibleViolations: true,
11731173
isOneTransactionReport: true,
1174-
isReportStatePending: false,
1174+
shouldShowStatusAsPending: false,
11751175
isWaitingOnBankAccount: false,
11761176
keyForList: '11111',
11771177
managerID: 18439984,
@@ -1280,7 +1280,7 @@ const transactionReportGroupListItems = [
12801280
formattedTo: 'Approver',
12811281
hasVisibleViolations: false,
12821282
isOneTransactionReport: false,
1283-
isReportStatePending: false,
1283+
shouldShowStatusAsPending: false,
12841284
isOwnPolicyExpenseChat: false,
12851285
isWaitingOnBankAccount: false,
12861286
managerID: 1111111,
@@ -1461,7 +1461,7 @@ const transactionReportGroupListItems = [
14611461
},
14621462
hasVisibleViolations: false,
14631463
isOneTransactionReport: true,
1464-
isReportStatePending: false,
1464+
shouldShowStatusAsPending: false,
14651465
isWaitingOnBankAccount: false,
14661466
keyForList: reportID5,
14671467
managerID: 18439984,

0 commit comments

Comments
 (0)