Skip to content

Commit

Permalink
Merge pull request #32849 from paultsimura/fix/32807-request-money-no…
Browse files Browse the repository at this point in the history
…t-found

fix: Handle brief NotFound page on the Request Money flow
  • Loading branch information
luacmartins authored Dec 12, 2023
2 parents 7e665f1 + c78c451 commit c21f455
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/pages/iou/request/IOURequestStartPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import DragAndDropProvider from '@components/DragAndDrop/Provider';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import TabSelector from '@components/TabSelector/TabSelector';
Expand Down Expand Up @@ -108,6 +109,12 @@ function IOURequestStartPage({
[previousIOURequestType, reportID, isFromGlobalCreate],
);

if (!transaction.transactionID) {
// The draft transaction is initialized only after the component is mounted,
// which will lead to briefly displaying the Not Found page without this loader.
return <FullScreenLoadingIndicator />;
}

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down
9 changes: 7 additions & 2 deletions src/pages/iou/request/step/withFullTransactionOrNotFound.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useIsFocused} from '@react-navigation/native';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React from 'react';
Expand Down Expand Up @@ -31,9 +32,13 @@ export default function (WrappedComponent) {
transaction: {transactionID},
} = props;

// If the transaction does not have a transactionID, then the transaction no longer exists in Onyx as a full transaction and the not-found page should be shown
const isFocused = useIsFocused();

// If the transaction does not have a transactionID, then the transaction no longer exists in Onyx as a full transaction and the not-found page should be shown.
// In addition, the not-found page should be shown only if the component screen's route is active (i.e. is focused).
// This is to prevent it from showing when the modal is being dismissed while navigating to a different route (e.g. on requesting money).
if (!transactionID) {
return <FullPageNotFoundView shouldShow />;
return <FullPageNotFoundView shouldShow={isFocused} />;
}

return (
Expand Down

0 comments on commit c21f455

Please sign in to comment.