Skip to content

Commit

Permalink
Merge pull request #50546 from nkdengineer/fix/50107
Browse files Browse the repository at this point in the history
fix: Not here page opens when opening distance receipt from another workspace
  • Loading branch information
pecanoro authored Oct 15, 2024
2 parents e61b1fb + ef00285 commit 2d9a28f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,10 @@ const ROUTES = {

TRANSACTION_RECEIPT: {
route: 'r/:reportID/transaction/:transactionID/receipt',
getRoute: (reportID: string, transactionID: string, readonly = false) => `r/${reportID}/transaction/${transactionID}/receipt${readonly ? '?readonly=true' : ''}` as const,
getRoute: (reportID: string, transactionID: string, readonly = false, isFromReviewDuplicates = false) =>
`r/${reportID}/transaction/${transactionID}/receipt?readonly=${readonly}${isFromReviewDuplicates ? '&isFromReviewDuplicates=true' : ''}` as const,
},

TRANSACTION_DUPLICATE_REVIEW_PAGE: {
route: 'r/:threadReportID/duplicates/review',
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review` as const, backTo),
Expand Down
6 changes: 5 additions & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ type MoneyRequestViewProps = {
/** Whether we should show Money Request with disabled all fields */
readonly?: boolean;

/** whether or not this report is from review duplicates */
isFromReviewDuplicates?: boolean;

/** Updated transaction to show in duplicate transaction flow */
updatedTransaction?: OnyxEntry<OnyxTypes.Transaction>;
};
Expand All @@ -75,7 +78,7 @@ const getTransactionID = (report: OnyxEntry<OnyxTypes.Report>, parentReportActio
return originalMessage?.IOUTransactionID ?? -1;
};

function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = false, updatedTransaction}: MoneyRequestViewProps) {
function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = false, updatedTransaction, isFromReviewDuplicates = false}: MoneyRequestViewProps) {
const theme = useTheme();
const styles = useThemeStyles();
const session = useSession();
Expand Down Expand Up @@ -508,6 +511,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
transaction={updatedTransaction ?? transaction}
enablePreviewModal
readonly={readonly || !canEditReceipt}
isFromReviewDuplicates={isFromReviewDuplicates}
/>
</View>
)}
Expand Down
11 changes: 10 additions & 1 deletion src/components/ReportActionItem/ReportActionItemImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ type ReportActionItemImageProps = {

/** Whether the receipt is not editable */
readonly?: boolean;

/** whether or not this report is from review duplicates */
isFromReviewDuplicates?: boolean;
};

/**
Expand All @@ -75,6 +78,7 @@ function ReportActionItemImage({
isSingleImage = true,
readonly = false,
shouldMapHaveBorderRadius,
isFromReviewDuplicates = false,
}: ReportActionItemImageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -135,7 +139,12 @@ function ReportActionItemImage({
style={[styles.w100, styles.h100, styles.noOutline as ViewStyle]}
onPress={() =>
Navigation.navigate(
ROUTES.TRANSACTION_RECEIPT.getRoute(transactionThreadReport?.reportID ?? report?.reportID ?? '-1', transaction?.transactionID ?? '-1', readonly),
ROUTES.TRANSACTION_RECEIPT.getRoute(
transactionThreadReport?.reportID ?? report?.reportID ?? '-1',
transaction?.transactionID ?? '-1',
readonly,
isFromReviewDuplicates,
),
)
}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,7 @@ type AuthScreensParamList = CentralPaneScreensParamList &
reportID: string;
transactionID: string;
readonly?: boolean;
isFromReviewDuplicates?: boolean;
};
[SCREENS.CONNECTION_COMPLETE]: undefined;
};
Expand Down
1 change: 1 addition & 0 deletions src/pages/TransactionDuplicate/Confirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function Confirmation() {
report={report}
shouldShowAnimatedBackground={false}
readonly
isFromReviewDuplicates
updatedTransaction={transaction as OnyxEntry<Transaction>}
/>
</ShowContextMenuContext.Provider>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/TransactionReceiptPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function TransactionReceipt({route}: TransactionReceiptProps) {

const isLocalFile = receiptURIs.isLocalFile;
const readonly = route.params.readonly ?? false;
const isFromReviewDuplicates = route.params.isFromReviewDuplicates ?? false;

const parentReportAction = ReportActionUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1');
const canEditReceipt = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT);
Expand Down Expand Up @@ -61,7 +62,8 @@ function TransactionReceipt({route}: TransactionReceiptProps) {
const isTrackExpenseReport = ReportUtils.isTrackExpenseReport(report);

// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage = isTrackExpenseReport || transaction?.reportID === CONST.REPORT.SPLIT_REPORTID ? !transaction : (moneyRequestReportID ?? '-1') !== transaction?.reportID;
const shouldShowNotFoundPage =
isTrackExpenseReport || transaction?.reportID === CONST.REPORT.SPLIT_REPORTID || isFromReviewDuplicates ? !transaction : (moneyRequestReportID ?? '-1') !== transaction?.reportID;

return (
<AttachmentModal
Expand Down

0 comments on commit 2d9a28f

Please sign in to comment.