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: Handle brief NotFound page on the Request Money flow #32849

Merged
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
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],
);

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 />;
}
Comment on lines +112 to +116
Copy link
Contributor Author

@paultsimura paultsimura Dec 11, 2023

Choose a reason for hiding this comment

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

@tgolen even though this was not in the original proposal, I've noticed that the NotFound page shows also while the modal is opening. The root cause here is different – it's caused by the draft transaction being initialized only after the component is mounted, by calling IOU.startMoneyRequest_temporaryForRefactor.
Please let me know if you think this change is not suitable here – I couldn't come up with a better fix for this case so far.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for digging into that. I think this fix is fine and I 💚 the fix here.


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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind updating this comment to explain why isFocused is part of the logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✔️

// 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
Loading