Skip to content

Commit

Permalink
Merge pull request Expensify#31529 from dukenv0307/fix/29115-open-des…
Browse files Browse the repository at this point in the history
…cription-when-login-with-deeplink

Login via deeplink should open modal in request money
  • Loading branch information
robertjchen authored May 31, 2024
2 parents 5699ae3 + 0103f4c commit 1ce235f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
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);
// 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

0 comments on commit 1ce235f

Please sign in to comment.