Block report submission when strict policy rules are enabled with violations#72663
Conversation
| dates: 'Dates', | ||
| rates: 'Rates', | ||
| submitsTo: ({name}: SubmitsToParams) => `Submits to ${name}`, | ||
| waitingForSubmitterToFixViolations: 'Waiting for you to fix the issue(s). Your admins have restricted submission of expenses that have violations.', |
There was a problem hiding this comment.
@jamesdeanexpensify is asking for a small copy update here @abzokhattab.
'Waiting for you to fix the issue(s). Your admins have restricted submission of expenses with violations.',
There was a problem hiding this comment.
I have a different question: should we translate this message into other languages, or keep it in English? In NextStepUtils.ts, all the text is hardcoded in English ... should we follow the same pattern? or translate it?
There was a problem hiding this comment.
Good point, if this is a NextSteps text showing at the report header and that is all in english right now, I think we should not translate only this one now. The transactions for them all would possibly come later.
There was a problem hiding this comment.
Okay, I kept it hardcoded and moved this logic to NextStepUtils.ts, similar to the buildOptimisticNextStepForPreventSelfApprovalsEnabled function to keep the optimistic values logic in one place and not scattered .. commit details: d48987b
|
The pr is now ready |
|
Wahooo! @akinwale can you prioritise the review today, please? |
Will do. |
Reviewer Checklist
Screenshots/VideosMacOS: Chrome / Safari72663-web.mp4 |
NikkiWines
left a comment
There was a problem hiding this comment.
Looks good - a couple of NABs and questions
|
@abzokhattab LEt me know in slack once you address these, thanks! |
Performance Violations Found❌ PERF-6 - Use specific properties as hook dependencies File: src/components/MoneyReportHeader.tsx The dependencies violations and transactions are entire objects/arrays. This causes the hook to re-execute whenever any property changes, even unrelated ones. Fix: Use specific properties instead:
❌ PERF-6 - Use specific properties as hook dependencies File: src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx The dependencies include entire objects like violations, iouReport, policy, transactions, and invoiceReceiverPolicy. This causes unnecessary re-executions when unrelated properties change. Fix: Use specific properties from these objects instead of passing the entire objects. |
HelpDot Documentation ReviewOverall AssessmentThis PR (#72663) focuses entirely on implementing functionality to block report submission when strict policy rules are enabled with violations. No documentation files were modified in this PR. Analysis Summary
Documentation Impact AssessmentWhile this PR introduces new user-facing functionality (blocking report submission with policy violations), it does not include any accompanying documentation updates. Key Findings
RecommendationsSince this PR introduces a significant change to user workflow (blocking report submission), consider:
ConclusionNo documentation review needed for this PR as it contains no documentation changes. However, this feature may warrant future documentation updates to help users understand the new strict policy enforcement behavior. Note: This assessment focuses on documentation quality standards since no documentation files were present in this PR. |
|
@kacper-mikolajczak @adamgrzybowski this comment I think seems a bit off on this PR #72663 (comment) I dont think there is other way to implement this |
|
@abzokhattab There seems to be conflicts |
|
fixed |
| */ | ||
| function useStrictPolicyRules(): UseStrictPolicyRulesResult { | ||
| const [myDomainSecurityGroups] = useOnyx(ONYXKEYS.MY_DOMAIN_SECURITY_GROUPS, {canBeMissing: true}); | ||
| const [securityGroups] = useOnyx(ONYXKEYS.COLLECTION.SECURITY_GROUP, {canBeMissing: true}); |
There was a problem hiding this comment.
I wonder how we could incorporate the selector for the groupID here already since it's dependent on the other useOnyx @TMisiukiewicz
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.2.37-1 🚀
|
|
@abzokhattab PR is failing with original bug ID #70990 1761309673062.72663_desktop.mp41761310071470.72663_iOS.mp4 |
@izarutskaya can you expand on that? How is it failing? Your video looks like it's behaving as expected. The user is prevented from submitting a report with this restriction.
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.2.37-8 🚀
|
You are clearly right @mountiny! These are not actual violations - I will take a look on how we could improve PERF-6 rule detection and get back to you. |
| const optimisticNextStep = isSubmitterSameAsNextApprover && policy?.preventSelfApproval ? buildOptimisticNextStepForPreventSelfApprovalsEnabled() : nextStep; | ||
| let optimisticNextStep = isSubmitterSameAsNextApprover && policy?.preventSelfApproval ? buildOptimisticNextStepForPreventSelfApprovalsEnabled() : nextStep; | ||
|
|
||
| if (shouldBlockSubmit && isReportOwner(moneyRequestReport)) { |
There was a problem hiding this comment.
In #73426, we decided to only show the violation with open expense report.
More details in:
#73426 (comment)






Explanation of Change
Fixed Issues
$ #70990
PROPOSAL: #70990 (comment)
Tests
Prerequisites:
Offline tests
Same as tests
QA Steps
same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2025-10-19.at.00.28.42.mov
Android: mWeb Chrome
Screen.Recording.2025-10-19.at.00.34.36.mov
iOS: Native
Screen.Recording.2025-10-19.at.00.28.42.mov
iOS: mWeb Safari
Screen.Recording.2025-10-19.at.00.34.36.mov
MacOS: Chrome / Safari
https://github.com/user-attachments/assets/fb9c340a-ff1f-46f0-9477-01c0b7b58b63MacOS: Desktop
Screen.Recording.2025-10-19.at.00.35.18.mov