Skip to content

Commit

Permalink
Merge pull request #37176 from FitseTLT/fix-deeplink-tag-page-bug
Browse files Browse the repository at this point in the history
Fix - An employee can access in a paid IOU the tag selection menu via a URL request
  • Loading branch information
neil-marcellini authored Mar 5, 2024
2 parents 4d978aa + 1b084e5 commit a36b0fc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
17 changes: 16 additions & 1 deletion src/pages/iou/request/step/IOURequestStepTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import compose from '@libs/compose';
import * as IOUUtils from '@libs/IOUUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import {canEditMoneyRequest} from '@libs/ReportUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import reportActionPropTypes from '@pages/home/report/reportActionPropTypes';
import reportPropTypes from '@pages/reportPropTypes';
import {policyPropTypes} from '@pages/workspace/withPolicy';
import * as IOU from '@userActions/IOU';
Expand Down Expand Up @@ -42,6 +44,9 @@ const propTypes = {

/** Collection of tags attached to a policy */
policyTags: tagPropTypes,

/** The actions from the parent report */
parentReportActions: PropTypes.shape(reportActionPropTypes),
};

const defaultProps = {
Expand All @@ -50,6 +55,7 @@ const defaultProps = {
policyTags: null,
policyCategories: null,
transaction: {},
parentReportActions: {},
};

function IOURequestStepTag({
Expand All @@ -61,6 +67,7 @@ function IOURequestStepTag({
params: {action, tagIndex: rawTagIndex, transactionID, backTo, iouType},
},
transaction,
parentReportActions,
}) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand All @@ -71,6 +78,10 @@ function IOURequestStepTag({
const tag = TransactionUtils.getTag(transaction, tagIndex);
const isEditing = action === CONST.IOU.ACTION.EDIT;
const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT;
const parentReportAction = parentReportActions[report.parentReportActionID];

// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage = isEditing && !canEditMoneyRequest(parentReportAction);

const navigateBack = () => {
Navigation.goBack(backTo);
Expand Down Expand Up @@ -103,11 +114,11 @@ function IOURequestStepTag({
onBackButtonPress={navigateBack}
shouldShowWrapper
testID={IOURequestStepTag.displayName}
shouldShowNotFoundPage={shouldShowNotFoundPage}
>
{({insets}) => (
<>
<Text style={[styles.ph5, styles.pv3]}>{translate('iou.tagSelection', {tagName: policyTagListName})}</Text>

<TagPicker
policyID={report.policyID}
tag={policyTagListName}
Expand Down Expand Up @@ -139,5 +150,9 @@ export default compose(
policyTags: {
key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`,
},
parentReportActions: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`,
canEvict: false,
},
}),
)(IOURequestStepTag);
40 changes: 19 additions & 21 deletions src/pages/iou/request/step/StepScreenWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ const defaultProps = {
function StepScreenWrapper({testID, headerTitle, onBackButtonPress, onEntryTransitionEnd, children, shouldShowWrapper, shouldShowNotFoundPage, includeSafeAreaPaddingBottom}) {
const styles = useThemeStyles();

if (shouldShowNotFoundPage) {
return <FullPageNotFoundView shouldShow />;
}

if (!shouldShowWrapper) {
return children;
return <FullPageNotFoundView shouldShow={shouldShowNotFoundPage}>{children}</FullPageNotFoundView>;
}

return (
Expand All @@ -59,22 +55,24 @@ function StepScreenWrapper({testID, headerTitle, onBackButtonPress, onEntryTrans
shouldEnableMaxHeight={DeviceCapabilities.canUseTouchScreen()}
>
{({insets, safeAreaPaddingBottomStyle, didScreenTransitionEnd}) => (
<View style={[styles.flex1]}>
<HeaderWithBackButton
title={headerTitle}
onBackButtonPress={onBackButtonPress}
/>
{
// If props.children is a function, call it to provide the insets to the children.
_.isFunction(children)
? children({
insets,
safeAreaPaddingBottomStyle,
didScreenTransitionEnd,
})
: children
}
</View>
<FullPageNotFoundView shouldShow={shouldShowNotFoundPage}>
<View style={[styles.flex1]}>
<HeaderWithBackButton
title={headerTitle}
onBackButtonPress={onBackButtonPress}
/>
{
// If props.children is a function, call it to provide the insets to the children.
_.isFunction(children)
? children({
insets,
safeAreaPaddingBottomStyle,
didScreenTransitionEnd,
})
: children
}
</View>
</FullPageNotFoundView>
)}
</ScreenWrapper>
);
Expand Down

0 comments on commit a36b0fc

Please sign in to comment.