You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$500] Web - Admin can submit and approve their own report when "Prevent Self-Approval" is on #36425
Version Number: v1.4.40-4 Reproducible in staging?: y Reproducible in production?: y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: Applause - Internal Team Slack conversation:
Admin will be prevented from submitting and approving the report as indicated by this line " Looks like you're submitting to yourself. Approving your own reports is forbidden by your policy." in Next step message.
Actual Result:
Admin is able to submit and approve their own report when "Prevent Self-Approval" is enabled.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
changed the title [-]Web - Admin can submit and approve their own report when "Prevent Self-Approval" is on[/-][+][$500] Web - Admin can submit and approve their own report when "Prevent Self-Approval" is on[/+]on Feb 13, 2024
Please re-state the problem that we are trying to solve in this issue.
We are able to approve reports in newdot when we configured on old dot to now allow this.
What is the root cause of that problem?
We are not using the logic isPreventSelfApprovalEnabled && isSelfApproval to decide whether or not to disable to approval action. We are using this condition however to decide whethhr or not to show the information that its not allowed.
What changes do you think we should make in order to solve the problem?
We can use the condition that determines isPreventSelfApprovalEnabled && isSelfApproval to disable to approval of the report. The back end is catching this error however we should prevent the user action.
We can additionally decide to just remove the approval button as well if this condition is met.
The conditions that determine the rendering of the button is found here:
Note that there are two buttons on the same component (mobile/desktop) and the logic must be applied to both.
Similar logic needs to be implemented on ReportPreview.tsx to hide/show or disable/enable the Submit button from the report preview.
Here's a couple of screenshots:
There's also another issue here with the APPROVAL. Currently the front end will show the "Oops, you can't submit to yourself" message but if it's already submitted, it will not show a similar message when the next action is "Approve". See screenshot.
If you click approve the backend won't let you because you can't approve your own reports.
I propose we apply a similar logic to check for self-approval here:
text: ' by your policy. Please submit this report to someone else or contact your admin to change the person you submit to.',
},
];
For the sake of DRY, make the logic above use the new isAllowedToSumitDraftExpenseReport (open to better name here as it's gonna be used for both submit and approve). method as well
Once this part is taken care of we also have to disable the approve button on the FE. We can do this by passing isDisabled="true" to the <SettlementButton> component on both ReportPreview.tsx and MoneyReportHeader.tsx.
There might also be yet another issue where the FE is allowing us to Pay before we approve:
If this is really not intentional, we need to update the shouldShowPayButton logic here:
What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
@jeremy-croff Thank you for your proposal. There is not much details in your proposal and you are only suggesting to disable approve button whereas in OP expected result is to prevent user from submitting proposal to themself when self approving is disabled.
This looks like a bug we'd want a regression test for, do you agree @alitoshmatov ? IF so, please fill out the BZ checklist below.
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@] The PR that introduced the bug has been identified. Link to the PR:
[@] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
[@] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
[@] Determine if we should create a regression test for this bug.
[@] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
[@bz] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: No need
Determine if we should create a regression test for this bug. No need
Are we should we don't want a regression test for this? It was a bug that didn't come from an existing regression test. @alitoshmatov can you provide reasoning why you don't think we need? @lakchote , what do you think? Here's the PR
@mallenexpensify Yep, we'll have to create a new one. The test steps given in the PR description #34450 look comprehensive enough to me. Let me know if you need any help with those.
Based on this comment I think existing regression test steps are the same as test steps in #34450 which caught this issue as OP states:
Activity
[-]Web - Admin can submit and approve their own report when "Prevent Self-Approval" is on[/-][+][$500] Web - Admin can submit and approve their own report when "Prevent Self-Approval" is on[/+]melvin-bot commentedon Feb 13, 2024
Job added to Upwork: https://www.upwork.com/jobs/~011beabd7ddef2a97c
melvin-bot commentedon Feb 13, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @alitoshmatov (
External)melvin-bot commentedon Feb 13, 2024
Triggered auto assignment to @kevinksullivan (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.kbecciv commentedon Feb 13, 2024
We think that this bug might be related #wave7-collect-approvers
CC @RachCHopkins
jeremy-croff commentedon Feb 13, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
We are able to approve reports in newdot when we configured on old dot to now allow this.
What is the root cause of that problem?
We are not using the logic
isPreventSelfApprovalEnabled && isSelfApprovalto decide whether or not to disable to approval action. We are using this condition however to decide whethhr or not to show the information that its not allowed.What changes do you think we should make in order to solve the problem?
We can use the condition that determines
isPreventSelfApprovalEnabled && isSelfApprovalto disable to approval of the report. The back end is catching this error however we should prevent the user action.We can additionally decide to just remove the approval button as well if this condition is met.
The conditions that determine the rendering of the button is found here:
App/src/components/SettlementButton.tsx
Line 36 in 19e2849
What alternative solutions did you explore? (Optional)
barros001 commentedon Feb 13, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Admin is allowed to approve it's own expense report even when "Prevent Self-Approval" is enabled.
What is the root cause of that problem?
The FE does not check is the user is self approving and always display the submit button. This can be seen here:
App/src/components/MoneyReportHeader.tsx
Line 81 in d50d603
App/src/components/MoneyReportHeader.tsx
Lines 133 to 142 in d50d603
What changes do you think we should make in order to solve the problem?
We create a new method on ReportUtils.ts called
isAllowedToSumitDraftExpenseReportand use it as part of theshouldShowSubmitButtonlogic.We then enable/disable the Submit button based on the value of
isAllowedToSumitDraftExpenseReport, as follows:Note that there are two buttons on the same component (mobile/desktop) and the logic must be applied to both.
Similar logic needs to be implemented on ReportPreview.tsx to hide/show or disable/enable the Submit button from the report preview.
Here's a couple of screenshots:
There's also another issue here with the APPROVAL. Currently the front end will show the "Oops, you can't submit to yourself" message but if it's already submitted, it will not show a similar message when the next action is "Approve". See screenshot.
If you click approve the backend won't let you because you can't approve your own reports.
I propose we apply a similar logic to check for self-approval here:
App/src/libs/NextStepUtils.ts
Lines 188 to 243 in d50d603
Using similar logic we have here:
App/src/libs/NextStepUtils.ts
Lines 163 to 182 in d50d603
For the sake of DRY, make the logic above use the new
isAllowedToSumitDraftExpenseReport(open to better name here as it's gonna be used for both submit and approve). method as wellOnce this part is taken care of we also have to disable the approve button on the FE. We can do this by passing
isDisabled="true"to the<SettlementButton>component on bothReportPreview.tsxandMoneyReportHeader.tsx.There might also be yet another issue where the FE is allowing us to
Paybefore we approve:If this is really not intentional, we need to update the
shouldShowPayButtonlogic here:App/src/components/ReportActionItem/ReportPreview.tsx
Lines 219 to 222 in 9c4c4ac
And here:
App/src/components/MoneyReportHeader.tsx
Lines 79 to 82 in 9c4c4ac
To check if report is approved or not.
What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
alitoshmatov commentedon Feb 16, 2024
@jeremy-croff Thank you for your proposal. There is not much details in your proposal and you are only suggesting to disable approve button whereas in OP expected result is to prevent user from submitting proposal to themself when self approving is disabled.
45 remaining items
alitoshmatov commentedon May 22, 2024
Accepted the offer
alitoshmatov commentedon Jun 2, 2024
@kevinksullivan Bump
mallenexpensify commentedon Jun 19, 2024
Contributor: @barros001 paid $500 via Upwork (by Kev, as mentioned above)
Contributor+: @alitoshmatov paid $500 via Upwork
This looks like a bug we'd want a regression test for, do you agree @alitoshmatov ? IF so, please fill out the BZ checklist below.
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
alitoshmatov commentedon Jun 23, 2024
alitoshmatov commentedon Jun 23, 2024
@mallenexpensify Completed the checklist
mallenexpensify commentedon Jun 24, 2024
Are we should we don't want a regression test for this? It was a bug that didn't come from an existing regression test.
@alitoshmatov can you provide reasoning why you don't think we need?
@lakchote , what do you think? Here's the PR
kevinksullivan commentedon Jun 26, 2024
Waiting for @alitoshmatov response here
alitoshmatov commentedon Jun 27, 2024
@mallenexpensify I think regression tests created in this #28771 should be sufficient.
Based on this comment I think existing regression test steps are the same as test steps in #34450 which caught this issue as OP states:
But we can create a new regression test specifically for this case if needed, let me know your thoughts
mallenexpensify commentedon Jun 28, 2024
Thanks @alitoshmatov , I agree, closing
TR GH is here - https://github.com/Expensify/Expensify/issues/372499
Section is likely this one (there are many)
