-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Don't allow employee to delete submitted request #35744
Changes from all commits
e0ae249
07fc3df
943e2a1
8ff8453
7fe73c2
177e65d
c5b0efe
14f1297
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 | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,6 +9,7 @@ import useWindowDimensions from '@hooks/useWindowDimensions'; | |||||||||||||||||||||||
import compose from '@libs/compose'; | ||||||||||||||||||||||||
import * as HeaderUtils from '@libs/HeaderUtils'; | ||||||||||||||||||||||||
import Navigation from '@libs/Navigation/Navigation'; | ||||||||||||||||||||||||
import * as PolicyUtils from '@libs/PolicyUtils'; | ||||||||||||||||||||||||
import * as ReportActionsUtils from '@libs/ReportActionsUtils'; | ||||||||||||||||||||||||
import * as ReportUtils from '@libs/ReportUtils'; | ||||||||||||||||||||||||
import * as TransactionUtils from '@libs/TransactionUtils'; | ||||||||||||||||||||||||
|
@@ -82,16 +83,21 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction, | |||||||||||||||||||||||
|
||||||||||||||||||||||||
const isScanning = TransactionUtils.hasReceipt(transaction) && TransactionUtils.isReceiptBeingScanned(transaction); | ||||||||||||||||||||||||
const isPending = TransactionUtils.isExpensifyCardTransaction(transaction) && TransactionUtils.isPending(transaction); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
const canModifyRequest = isActionOwner && !isSettled && !isApproved && !ReportActionsUtils.isDeletedAction(parentReportAction); | ||||||||||||||||||||||||
let canDeleteRequest = canModifyRequest; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if (ReportUtils.isPaidGroupPolicyExpenseReport(moneyRequestReport)) { | ||||||||||||||||||||||||
// If it's a paid policy expense report, only allow deleting the request if it's not submitted or the user is the policy admin | ||||||||||||||||||||||||
canDeleteRequest = canDeleteRequest && (ReportUtils.isDraftExpenseReport(moneyRequestReport) || PolicyUtils.isPolicyAdmin(policy)); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
Comment on lines
+87
to
+92
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.
Suggested change
NAB. But I think using const is better for this case. It's easier to know where canDeleteRequest value is coming from 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. Hmm, I feel the current code is easier to read |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||
if (canModifyRequest) { | ||||||||||||||||||||||||
if (canDeleteRequest) { | ||||||||||||||||||||||||
return; | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
setIsDeleteModalVisible(false); | ||||||||||||||||||||||||
}, [canModifyRequest]); | ||||||||||||||||||||||||
}, [canDeleteRequest]); | ||||||||||||||||||||||||
const threeDotsMenuItems = [HeaderUtils.getPinMenuItem(report)]; | ||||||||||||||||||||||||
if (canModifyRequest) { | ||||||||||||||||||||||||
if (!TransactionUtils.hasReceipt(transaction)) { | ||||||||||||||||||||||||
|
@@ -110,11 +116,13 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction, | |||||||||||||||||||||||
), | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
threeDotsMenuItems.push({ | ||||||||||||||||||||||||
icon: Expensicons.Trashcan, | ||||||||||||||||||||||||
text: translate('reportActionContextMenu.deleteAction', {action: parentReportAction}), | ||||||||||||||||||||||||
onSelected: () => setIsDeleteModalVisible(true), | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
if (canDeleteRequest) { | ||||||||||||||||||||||||
threeDotsMenuItems.push({ | ||||||||||||||||||||||||
icon: Expensicons.Trashcan, | ||||||||||||||||||||||||
text: translate('reportActionContextMenu.deleteAction', {action: parentReportAction}), | ||||||||||||||||||||||||
onSelected: () => setIsDeleteModalVisible(true), | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||
|
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.
I tested and found out that we can't add a receipt on a submitted expense too, so I decided to move the condition here.
But if the submitted expense has a receipt, we can replace/delete it.
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.
I tested and it seems that I can add a receipt on a submitted expense. Can you please double check?
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.
Let me check once again.
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.
Yeah, I can add a receipt on a submitted request. Updated