-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix - An employee can access in a paid IOU the tag selection menu via a URL request #37176
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
Changes from all commits
46cb964
ca95fb3
cb31a15
1b084e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -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 = { | ||
|
@@ -50,6 +55,7 @@ const defaultProps = { | |
policyTags: null, | ||
policyCategories: null, | ||
transaction: {}, | ||
parentReportActions: {}, | ||
}; | ||
|
||
function IOURequestStepTag({ | ||
|
@@ -61,6 +67,7 @@ function IOURequestStepTag({ | |
params: {action, tagIndex: rawTagIndex, transactionID, backTo, iouType}, | ||
}, | ||
transaction, | ||
parentReportActions, | ||
}) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While updating not found logic here, the case of P2P request could also have been considered as it doesn't make sense to show tags page in P2P. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't know how this pr is considered as the offending PR to that issue as it wasn't merged when that issue was created and this pr is still younger than yours 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no specific offending PR for #37207. |
||
|
||
const navigateBack = () => { | ||
Navigation.goBack(backTo); | ||
|
@@ -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} | ||
|
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB: I think we generally prefer import * in our style, but I can't actually find a rule about that.