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

Login via deeplink should open modal in request money #31529

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
6 changes: 3 additions & 3 deletions src/pages/iou/request/step/IOURequestStepDate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ const IOURequestStepDateWithOnyx = withOnyx<IOURequestStepDateProps, IOURequestS
})(IOURequestStepDate);

// eslint-disable-next-line rulesdir/no-negated-variables
const IOURequestStepDateWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepDateWithOnyx);
const IOURequestStepDateWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepDateWithOnyx);
// eslint-disable-next-line rulesdir/no-negated-variables
const IOURequestStepDateWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepDateWithWritableReportOrNotFound);
const IOURequestStepDateWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepDateWithFullTransactionOrNotFound);

export default IOURequestStepDateWithFullTransactionOrNotFound;
export default IOURequestStepDateWithWritableReportOrNotFound;
6 changes: 3 additions & 3 deletions src/pages/iou/request/step/IOURequestStepDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ const IOURequestStepDescriptionWithOnyx = withOnyx<IOURequestStepDescriptionProp
})(IOURequestStepDescription);

// eslint-disable-next-line rulesdir/no-negated-variables
const IOURequestStepDescriptionWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepDescriptionWithOnyx);
const IOURequestStepDescriptionWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepDescriptionWithOnyx);
Copy link
Contributor

Choose a reason for hiding this comment

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

@dukenv0307 I am not entirely sure on what changes we are making here since this PR is very old and the new changes are different than the accepted proposal.

Could you let me know the changes and why we need to do this and how will it fix the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you let me know the changes and why we need to do this and how will it fix the issue?

@abdulrahuman5196 The bug still happens after we refactor the edit flow. The RCA is we don't have the logic to display the loading page when the report is loading. My solution is we will handle this in withWritableReportOrNotFound HOC so all pages of money request flow can display a loading page when the report is loading. That's why we have to wrap that HOC on the outside.

// eslint-disable-next-line rulesdir/no-negated-variables
const IOURequestStepDescriptionWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepDescriptionWithWritableReportOrNotFound);
const IOURequestStepDescriptionWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepDescriptionWithFullTransactionOrNotFound);

export default IOURequestStepDescriptionWithFullTransactionOrNotFound;
export default IOURequestStepDescriptionWithWritableReportOrNotFound;
27 changes: 25 additions & 2 deletions src/pages/iou/request/step/withWritableReportOrNotFound.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type {RouteProp} from '@react-navigation/core';
import type {ComponentType, ForwardedRef, RefAttributes} from 'react';
import React, {forwardRef} from 'react';
import React, {forwardRef, useEffect} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import getComponentDisplayName from '@libs/getComponentDisplayName';
import type {MoneyRequestNavigatorParamList} from '@libs/Navigation/types';
import * as ReportUtils from '@libs/ReportUtils';
import * as ReportActions from '@userActions/Report';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
Expand All @@ -16,6 +18,9 @@ type WithWritableReportOrNotFoundOnyxProps = {
/** The report corresponding to the reportID in the route params */
report: OnyxEntry<Report>;

/** Whether the reports are loading. When false it means they are ready to be used. */
isLoadingApp: OnyxEntry<boolean>;

/** The draft report corresponding to the reportID in the route params */
reportDraft: OnyxEntry<Report>;
};
Expand Down Expand Up @@ -49,12 +54,27 @@ export default function <TProps extends WithWritableReportOrNotFoundProps<MoneyR
): React.ComponentType<Omit<TProps & RefAttributes<TRef>, keyof WithWritableReportOrNotFoundOnyxProps>> {
// eslint-disable-next-line rulesdir/no-negated-variables
function WithWritableReportOrNotFound(props: TProps, ref: ForwardedRef<TRef>) {
const {report = {reportID: ''}, route} = props;
const {report = {reportID: ''}, route, isLoadingApp = true} = props;
const iouTypeParamIsInvalid = !Object.values(CONST.IOU.TYPE)
.filter((type) => shouldIncludeDeprecatedIOUType || (type !== CONST.IOU.TYPE.REQUEST && type !== CONST.IOU.TYPE.SEND))
.includes(route.params?.iouType);
const isEditing = 'action' in route.params && route.params?.action === CONST.IOU.ACTION.EDIT;
const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report);

useEffect(() => {
if (Boolean(report?.reportID) || !route.params.reportID) {
return;
}

ReportActions.openReport(route.params.reportID);

// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

if (isEditing && isLoadingApp) {
return <FullScreenLoadingIndicator />;
}

if (iouTypeParamIsInvalid || !canUserPerformWriteAction) {
return <FullPageNotFoundView shouldShow />;
}
Expand All @@ -74,6 +94,9 @@ export default function <TProps extends WithWritableReportOrNotFoundProps<MoneyR
report: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID ?? '0'}`,
},
isLoadingApp: {
key: ONYXKEYS.IS_LOADING_APP,
},
reportDraft: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_DRAFT}${route.params.reportID ?? '0'}`,
},
Expand Down
Loading