Skip to content

Commit 3d868d7

Browse files
authored
Merge pull request Expensify#74856 from Krishna2323/krishna2323/issue/74616
fix: Reports - Filters become unresponsive after deleting the workspace.
2 parents 2d49ff4 + f70c628 commit 3d868d7

3 files changed

Lines changed: 95 additions & 96 deletions

File tree

src/pages/workspace/WorkspaceOverviewPage.tsx

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
277277
if (!isFocused || !prevIsPendingDelete || isPendingDelete) {
278278
return;
279279
}
280-
setIsDeleteModalOpen(false);
280+
281281
if (!policyLastErrorMessage) {
282282
goBackFromInvalidPolicy();
283283
return;
@@ -468,6 +468,52 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
468468
return renderDropdownMenu(secondaryActions);
469469
};
470470

471+
const modals = (
472+
<>
473+
<ConfirmModal
474+
title={translate('workspace.common.delete')}
475+
isVisible={isDeleteModalOpen}
476+
onConfirm={confirmDelete}
477+
onCancel={() => setIsDeleteModalOpen(false)}
478+
prompt={hasCardFeedOrExpensifyCard ? translate('workspace.common.deleteWithCardsConfirmation') : translate('workspace.common.deleteConfirmation')}
479+
confirmText={translate('common.delete')}
480+
cancelText={translate('common.cancel')}
481+
isConfirmLoading={isPendingDeletePolicy(policy)}
482+
danger
483+
/>
484+
<ConfirmModal
485+
title={translate('common.leaveWorkspace')}
486+
isVisible={isLeaveModalOpen}
487+
onConfirm={handleLeaveWorkspace}
488+
onCancel={() => setIsLeaveModalOpen(false)}
489+
prompt={confirmModalPrompt()}
490+
confirmText={translate('common.leave')}
491+
cancelText={translate('common.cancel')}
492+
danger
493+
/>
494+
<ConfirmModal
495+
title={translate('common.leaveWorkspace')}
496+
isVisible={isCannotLeaveWorkspaceModalOpen}
497+
onConfirm={() => {
498+
setIsCannotLeaveWorkspaceModalOpen(false);
499+
}}
500+
prompt={confirmModalPrompt()}
501+
confirmText={translate('common.buttonConfirm')}
502+
shouldShowCancelButton={false}
503+
success
504+
/>
505+
<ConfirmModal
506+
title={translate('workspace.common.delete')}
507+
isVisible={isDeleteWorkspaceErrorModalOpen}
508+
onConfirm={hideDeleteWorkspaceErrorModal}
509+
onCancel={hideDeleteWorkspaceErrorModal}
510+
prompt={policyLastErrorMessage}
511+
confirmText={translate('common.buttonConfirm')}
512+
shouldShowCancelButton={false}
513+
success={false}
514+
/>
515+
</>
516+
);
471517
return (
472518
<WorkspacePageWithSections
473519
headerText={translate('workspace.common.profile')}
@@ -482,6 +528,7 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
482528
onBackButtonPress={handleBackButtonPress}
483529
addBottomSafeAreaPadding
484530
headerContent={!shouldUseNarrowLayout && getHeaderButtons()}
531+
modals={modals}
485532
>
486533
{(hasVBA?: boolean) => (
487534
<View style={[styles.flex1, styles.mt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
@@ -665,48 +712,6 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
665712
</OfflineWithFeedback>
666713
</Section>
667714
) : null}
668-
<ConfirmModal
669-
title={translate('workspace.common.delete')}
670-
isVisible={isDeleteModalOpen}
671-
onConfirm={confirmDelete}
672-
onCancel={() => setIsDeleteModalOpen(false)}
673-
prompt={hasCardFeedOrExpensifyCard ? translate('workspace.common.deleteWithCardsConfirmation') : translate('workspace.common.deleteConfirmation')}
674-
confirmText={translate('common.delete')}
675-
cancelText={translate('common.cancel')}
676-
isConfirmLoading={isPendingDeletePolicy(policy)}
677-
danger
678-
/>
679-
<ConfirmModal
680-
title={translate('common.leaveWorkspace')}
681-
isVisible={isLeaveModalOpen}
682-
onConfirm={handleLeaveWorkspace}
683-
onCancel={() => setIsLeaveModalOpen(false)}
684-
prompt={confirmModalPrompt()}
685-
confirmText={translate('common.leave')}
686-
cancelText={translate('common.cancel')}
687-
danger
688-
/>
689-
<ConfirmModal
690-
title={translate('common.leaveWorkspace')}
691-
isVisible={isCannotLeaveWorkspaceModalOpen}
692-
onConfirm={() => {
693-
setIsCannotLeaveWorkspaceModalOpen(false);
694-
}}
695-
prompt={confirmModalPrompt()}
696-
confirmText={translate('common.buttonConfirm')}
697-
shouldShowCancelButton={false}
698-
success
699-
/>
700-
<ConfirmModal
701-
title={translate('workspace.common.delete')}
702-
isVisible={isDeleteWorkspaceErrorModalOpen}
703-
onConfirm={hideDeleteWorkspaceErrorModal}
704-
onCancel={hideDeleteWorkspaceErrorModal}
705-
prompt={policyLastErrorMessage}
706-
confirmText={translate('common.buttonConfirm')}
707-
shouldShowCancelButton={false}
708-
success={false}
709-
/>
710715
</View>
711716
)}
712717
</WorkspacePageWithSections>

src/pages/workspace/WorkspacePageWithSections.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ type WorkspacePageWithSectionsProps = WithPolicyAndFullscreenLoadingProps &
8989
* If enabled, the content will have a bottom padding equal to account for the safe bottom area inset.
9090
*/
9191
addBottomSafeAreaPadding?: boolean;
92+
93+
/** Content to be added as modal */
94+
modals?: ReactNode;
9295
};
9396

9497
function fetchData(policyID: string | undefined, skipVBBACal?: boolean) {
@@ -124,6 +127,7 @@ function WorkspacePageWithSections({
124127
threeDotsMenuItems,
125128
shouldUseHeadlineHeader = true,
126129
addBottomSafeAreaPadding = false,
130+
modals,
127131
}: WorkspacePageWithSectionsProps) {
128132
const styles = useThemeStyles();
129133
const policyID = route.params?.policyID;
@@ -235,6 +239,7 @@ function WorkspacePageWithSections({
235239
</>
236240
)}
237241
</FullPageNotFoundView>
242+
{modals}
238243
</ScreenWrapper>
239244
);
240245
}

src/pages/workspace/WorkspacesListPage.tsx

Lines changed: 42 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ function WorkspacesListPage() {
125125
const icons = useMemoizedLazyExpensifyIcons(['Building', 'Exit', 'Copy', 'Star', 'Trashcan', 'Transfer', 'FallbackWorkspaceAvatar', 'Plus'] as const);
126126
const theme = useTheme();
127127
const styles = useThemeStyles();
128+
const expensifyIcons = useMemoizedLazyExpensifyIcons(['Building', 'Exit', 'Copy', 'Star', 'Trashcan', 'Transfer', 'Plus', 'FallbackWorkspaceAvatar']);
128129
const {translate, localeCompare} = useLocalize();
129130
const {isOffline} = useNetwork();
130131
const isFocused = useIsFocused();
@@ -339,15 +340,15 @@ function WorkspacesListPage() {
339340

340341
const threeDotsMenuItems: PopoverMenuItem[] = [
341342
{
342-
icon: icons.Building,
343+
icon: expensifyIcons.Building,
343344
text: translate('workspace.common.goToWorkspace'),
344345
onSelected: item.action,
345346
},
346347
];
347348

348349
if (!isOwner && (item.policyID !== preferredPolicyID || !isRestrictedToPreferredPolicy)) {
349350
threeDotsMenuItems.push({
350-
icon: icons.Exit,
351+
icon: expensifyIcons.Exit,
351352
text: translate('common.leave'),
352353
onSelected: callFunctionIfActionIsAllowed(() => {
353354
close(() => {
@@ -485,6 +486,8 @@ function WorkspacesListPage() {
485486
policyIDToDelete,
486487
preferredPolicyID,
487488
icons,
489+
expensifyIcons.Building,
490+
expensifyIcons.Exit,
488491
],
489492
);
490493

@@ -726,39 +729,7 @@ function WorkspacesListPage() {
726729
[getWorkspaceMenuItem, styles, translate],
727730
);
728731

729-
if (!workspaces.length && !domains.length) {
730-
return (
731-
<ScreenWrapper
732-
shouldEnablePickerAvoiding={false}
733-
shouldEnableMaxHeight
734-
testID={WorkspacesListPage.displayName}
735-
shouldShowOfflineIndicatorInWideScreen
736-
bottomContent={
737-
shouldUseNarrowLayout && (
738-
<NavigationTabBar
739-
selectedTab={NAVIGATION_TABS.WORKSPACES}
740-
shouldShowFloatingCameraButton={false}
741-
/>
742-
)
743-
}
744-
enableEdgeToEdgeBottomSafeAreaPadding={false}
745-
>
746-
<View style={styles.topBarWrapper}>
747-
<TopBar breadcrumbLabel={translate('common.workspaces')} />
748-
</View>
749-
{shouldShowLoadingIndicator ? (
750-
<View style={[styles.flex1]}>
751-
<FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
752-
</View>
753-
) : (
754-
<ScrollView contentContainerStyle={[styles.pt2, styles.flexGrow1, styles.flexShrink0]}>
755-
<WorkspacesEmptyStateComponent />
756-
</ScrollView>
757-
)}
758-
{shouldDisplayLHB && <NavigationTabBar selectedTab={NAVIGATION_TABS.WORKSPACES} />}
759-
</ScreenWrapper>
760-
);
761-
}
732+
const shouldShowEmptyState = !workspaces.length && !domains.length;
762733

763734
return (
764735
<ScreenWrapper
@@ -774,25 +745,43 @@ function WorkspacesListPage() {
774745
/>
775746
)
776747
}
748+
shouldEnableMaxHeight={shouldShowEmptyState}
777749
>
778-
<View style={styles.flex1}>
779-
<TopBar breadcrumbLabel={translate('common.workspaces')}>{!shouldUseNarrowLayout && <View style={[styles.pr2]}>{getHeaderButton()}</View>}</TopBar>
780-
{shouldUseNarrowLayout && <View style={[styles.ph5, styles.pt2]}>{getHeaderButton()}</View>}
781-
<FlatList
782-
ref={flatlistRef}
783-
data={data}
784-
onScrollToIndexFailed={(info) => {
785-
flatlistRef.current?.scrollToOffset({
786-
offset: info.averageItemLength * info.index,
787-
animated: true,
788-
});
789-
}}
790-
renderItem={renderItem}
791-
ListHeaderComponent={listHeaderComponent}
792-
keyboardShouldPersistTaps="handled"
793-
contentContainerStyle={styles.pb20}
794-
/>
795-
</View>
750+
{shouldShowEmptyState ? (
751+
<>
752+
<View style={styles.topBarWrapper}>
753+
<TopBar breadcrumbLabel={translate('common.workspaces')} />
754+
</View>
755+
{shouldShowLoadingIndicator ? (
756+
<View style={[styles.flex1]}>
757+
<FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
758+
</View>
759+
) : (
760+
<ScrollView contentContainerStyle={[styles.pt2, styles.flexGrow1, styles.flexShrink0]}>
761+
<WorkspacesEmptyStateComponent />
762+
</ScrollView>
763+
)}
764+
</>
765+
) : (
766+
<View style={styles.flex1}>
767+
<TopBar breadcrumbLabel={translate('common.workspaces')}>{!shouldUseNarrowLayout && <View style={[styles.pr2]}>{getHeaderButton()}</View>}</TopBar>
768+
{shouldUseNarrowLayout && <View style={[styles.ph5, styles.pt2]}>{getHeaderButton()}</View>}
769+
<FlatList
770+
ref={flatlistRef}
771+
data={data}
772+
onScrollToIndexFailed={(info) => {
773+
flatlistRef.current?.scrollToOffset({
774+
offset: info.averageItemLength * info.index,
775+
animated: true,
776+
});
777+
}}
778+
renderItem={renderItem}
779+
ListHeaderComponent={listHeaderComponent}
780+
keyboardShouldPersistTaps="handled"
781+
contentContainerStyle={styles.pb20}
782+
/>
783+
</View>
784+
)}
796785
<ConfirmModal
797786
title={translate('workspace.common.delete')}
798787
isVisible={isDeleteModalOpen}

0 commit comments

Comments
 (0)