Skip to content

Commit 589e414

Browse files
authored
Merge pull request #89136 from abbasifaizan70/88500
88500: Unexpected error does not appear in created report after enabling Failing network
2 parents ad21bb4 + d63c8d9 commit 589e414

1 file changed

Lines changed: 43 additions & 14 deletions

File tree

src/pages/inbox/ReportScreen.tsx

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ import {PortalHost} from '@gorhom/portal';
22
import React from 'react';
33
import type {ViewStyle} from 'react-native';
44
import {View} from 'react-native';
5+
import OfflineWithFeedback from '@components/OfflineWithFeedback';
56
import ScreenWrapper from '@components/ScreenWrapper';
67
import WideRHPOverlayWrapper from '@components/WideRHPOverlayWrapper';
78
import useActionListContextValue from '@hooks/useActionListContextValue';
89
import {useCurrentReportIDState} from '@hooks/useCurrentReportID';
10+
import useOnyx from '@hooks/useOnyx';
911
import useResponsiveLayout from '@hooks/useResponsiveLayout';
1012
import useSubmitToDestinationVisible from '@hooks/useSubmitToDestinationVisible';
1113
import useThemeStyles from '@hooks/useThemeStyles';
1214
import useViewportOffsetTop from '@hooks/useViewportOffsetTop';
15+
import {removeFailedReport} from '@libs/actions/Report';
1316
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
17+
import Navigation from '@libs/Navigation/Navigation';
1418
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
1519
import type {ReportsSplitNavigatorParamList, RightModalNavigatorParamList} from '@navigation/types';
1620
import CONST from '@src/CONST';
21+
import ONYXKEYS from '@src/ONYXKEYS';
1722
import SCREENS from '@src/SCREENS';
1823
import AccountManagerBanner from './AccountManagerBanner';
1924
import {AgentZeroStatusProvider} from './AgentZeroStatusContext';
@@ -63,6 +68,20 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
6368

6469
const actionListValue = useActionListContextValue();
6570

71+
const [reportPendingActionAndErrors] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportIDFromRoute}`, {
72+
selector: (r) => ({
73+
reportPendingAction: r?.pendingFields?.addWorkspaceRoom ?? r?.pendingFields?.createChat ?? r?.pendingFields?.createReport ?? r?.pendingFields?.reportName,
74+
reportErrors: r?.errorFields?.addWorkspaceRoom ?? r?.errorFields?.createChat ?? r?.errorFields?.createReport,
75+
}),
76+
});
77+
const {reportPendingAction, reportErrors} = reportPendingActionAndErrors ?? {};
78+
79+
const dismissReportCreationError = () => {
80+
Navigation.goBack(undefined, {
81+
afterTransition: () => removeFailedReport(reportIDFromRoute),
82+
});
83+
};
84+
6685
return (
6786
<WideRHPOverlayWrapper shouldWrap={route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT}>
6887
<ActionListContext.Provider value={actionListValue}>
@@ -87,20 +106,30 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
87106
{!shouldDeferNonEssentials && <ReportLifecycleHandler reportID={reportIDFromRoute} />}
88107
<ReportHeader />
89108
{!shouldDeferNonEssentials && <AccountManagerBanner reportID={reportIDFromRoute} />}
90-
<View style={[styles.flex1, styles.flexRow]}>
91-
{!shouldDeferNonEssentials && <WideRHPReceiptPanel />}
92-
<AgentZeroStatusProvider reportID={reportIDFromRoute}>
93-
<ConciergeDraftProvider reportID={reportIDFromRoute}>
94-
<View
95-
style={[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]}
96-
testID="report-actions-view-wrapper"
97-
>
98-
<ReportActionsList />
99-
{shouldDeferNonEssentials ? <ReportActionComposePlaceholder /> : <ReportFooter />}
100-
</View>
101-
</ConciergeDraftProvider>
102-
</AgentZeroStatusProvider>
103-
</View>
109+
<OfflineWithFeedback
110+
pendingAction={reportPendingAction}
111+
errors={reportErrors}
112+
onClose={dismissReportCreationError}
113+
needsOffscreenAlphaCompositing
114+
style={styles.flex1}
115+
contentContainerStyle={styles.flex1}
116+
errorRowStyles={[styles.ph5, styles.mv2]}
117+
>
118+
<View style={[styles.flex1, styles.flexRow]}>
119+
{!shouldDeferNonEssentials && <WideRHPReceiptPanel />}
120+
<AgentZeroStatusProvider reportID={reportIDFromRoute}>
121+
<ConciergeDraftProvider reportID={reportIDFromRoute}>
122+
<View
123+
style={[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]}
124+
testID="report-actions-view-wrapper"
125+
>
126+
<ReportActionsList />
127+
{shouldDeferNonEssentials ? <ReportActionComposePlaceholder /> : <ReportFooter />}
128+
</View>
129+
</ConciergeDraftProvider>
130+
</AgentZeroStatusProvider>
131+
</View>
132+
</OfflineWithFeedback>
104133
<PortalHost name="suggestions" />
105134
</ReportDragAndDropProvider>
106135
</LinkedActionNotFoundGuard>

0 commit comments

Comments
 (0)