Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Deleting workspace in connect bank account provides update currency error #21819

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 40 additions & 50 deletions src/pages/ReimbursementAccount/ContinueBankAccountSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ import * as Expensicons from '../../components/Icon/Expensicons';
import * as Illustrations from '../../components/Icon/Illustrations';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
import Button from '../../components/Button';
import compose from '../../libs/compose';
import CONST from '../../CONST';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';
import HeaderWithBackButton from '../../components/HeaderWithBackButton';
import MenuItem from '../../components/MenuItem';
import styles from '../../styles/styles';
import ScreenWrapper from '../../components/ScreenWrapper';
import Section from '../../components/Section';
import Text from '../../components/Text';
import withPolicy from '../workspace/withPolicy';
import * as ReimbursementAccountProps from './reimbursementAccountPropTypes';
import WorkspaceResetBankAccountModal from '../workspace/WorkspaceResetBankAccountModal';
import * as BankAccounts from '../../libs/actions/BankAccounts';
Expand All @@ -29,11 +26,6 @@ const propTypes = {
/** Callback to continue to the next step of the setup */
continue: PropTypes.func.isRequired,

/** Policy values needed in the component */
policy: PropTypes.shape({
name: PropTypes.string,
}).isRequired,

/* The workspace name */
policyName: PropTypes.string,

Expand All @@ -47,48 +39,46 @@ function ContinueBankAccountSetup(props) {
const pendingAction = lodashGet(props.reimbursementAccount, 'pendingAction', null);
return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<FullPageNotFoundView shouldShow={_.isEmpty(props.policy)}>
<HeaderWithBackButton
title={props.translate('workspace.common.connectBankAccount')}
subtitle={props.policyName}
shouldShowGetAssistanceButton
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_BANK_ACCOUNT}
/>
<ScrollView style={styles.flex1}>
<Section
title={props.translate('workspace.bankAccount.almostDone')}
icon={Illustrations.BankArrow}
<HeaderWithBackButton
title={props.translate('workspace.common.connectBankAccount')}
subtitle={props.policyName}
shouldShowGetAssistanceButton
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_BANK_ACCOUNT}
/>
<ScrollView style={styles.flex1}>
<Section
title={props.translate('workspace.bankAccount.almostDone')}
icon={Illustrations.BankArrow}
>
<OfflineWithFeedback
pendingAction={pendingAction}
errors={errors}
shouldShowErrorMessage
onClose={BankAccounts.resetReimbursementAccount}
>
<OfflineWithFeedback
pendingAction={pendingAction}
errors={errors}
shouldShowErrorMessage
onClose={BankAccounts.resetReimbursementAccount}
>
<Text>{props.translate('workspace.bankAccount.youreAlmostDone')}</Text>
<Button
text={props.translate('workspace.bankAccount.continueWithSetup')}
onPress={props.continue}
icon={Expensicons.Bank}
style={[styles.mv4]}
iconStyles={[styles.buttonCTAIcon]}
shouldShowRightIcon
large
success
isDisabled={Boolean(pendingAction) || !_.isEmpty(errors)}
/>
<MenuItem
title={props.translate('workspace.bankAccount.startOver')}
icon={Expensicons.RotateLeft}
onPress={() => BankAccounts.requestResetFreePlanBankAccount()}
shouldShowRightIcon
wrapperStyle={[styles.cardMenuItem]}
disabled={Boolean(pendingAction) || !_.isEmpty(errors)}
/>
</OfflineWithFeedback>
</Section>
</ScrollView>
</FullPageNotFoundView>
<Text>{props.translate('workspace.bankAccount.youreAlmostDone')}</Text>
<Button
text={props.translate('workspace.bankAccount.continueWithSetup')}
onPress={props.continue}
icon={Expensicons.Bank}
style={[styles.mv4]}
iconStyles={[styles.buttonCTAIcon]}
shouldShowRightIcon
large
success
isDisabled={Boolean(pendingAction) || !_.isEmpty(errors)}
/>
<MenuItem
title={props.translate('workspace.bankAccount.startOver')}
icon={Expensicons.RotateLeft}
onPress={() => BankAccounts.requestResetFreePlanBankAccount()}
shouldShowRightIcon
wrapperStyle={[styles.cardMenuItem]}
disabled={Boolean(pendingAction) || !_.isEmpty(errors)}
/>
</OfflineWithFeedback>
</Section>
</ScrollView>

{props.reimbursementAccount.shouldShowResetModal && <WorkspaceResetBankAccountModal reimbursementAccount={props.reimbursementAccount} />}
</ScreenWrapper>
Expand All @@ -99,4 +89,4 @@ ContinueBankAccountSetup.propTypes = propTypes;
ContinueBankAccountSetup.defaultProps = defaultProps;
ContinueBankAccountSetup.displayName = 'ContinueBankAccountSetup';

export default compose(withPolicy, withLocalize)(ContinueBankAccountSetup);
export default withLocalize(ContinueBankAccountSetup);
13 changes: 13 additions & 0 deletions src/pages/ReimbursementAccount/ReimbursementAccountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import HeaderWithBackButton from '../../components/HeaderWithBackButton';
import * as ReimbursementAccountProps from './reimbursementAccountPropTypes';
import reimbursementAccountDraftPropTypes from './ReimbursementAccountDraftPropTypes';
import withPolicy from '../workspace/withPolicy';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';

const propTypes = {
/** Plaid SDK token to use to initialize the widget */
Expand Down Expand Up @@ -329,6 +330,18 @@ class ReimbursementAccountPage extends React.Component {
const currentStep = achData.currentStep || CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT;
const policyName = lodashGet(this.props.policy, 'name');

if (_.isEmpty(this.props.policy)) {
return (
<ScreenWrapper>
<FullPageNotFoundView
shouldShow
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Coming from #23167:
This caused infinite loop when this page is opened from deeplink.
Navigation.goBack(ROUTES.SETTINGS_WORKSPACES) is the correct approach.

shouldShowLink
/>
</ScreenWrapper>
Comment on lines +335 to +341
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: we can update the NotFoundPage component to accept onBackButtonPress prop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

won't it more become like FullPageNotFoundView with an only diff of ScreenWrapper?

);
}

const isLoading = this.props.isLoadingReportData || this.props.account.isLoading || this.props.reimbursementAccount.isLoading;

// Prevent the full-page blocking offline view from being displayed for these steps if the device goes offline.
Expand Down