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
[HOLD for payment 2024-12-16] [$250] Web - Header - Approve button appears briefly when it shouldn't #52669
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Version Number: 9.0.63-3 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers):biruknew45+2101@gmail.com Issue reported by: Applause Internal Team
Please re-state the problem that we are trying to solve in this issue.
Web - Header - Approve button appears briefly when it shouldn't
What is the root cause of that problem?
For example we have 3 users: A (admin), B, and C
Admin: Add new approval workflow (from B and approval B), the BE will set the managerID for the approval to B because the approval is BE so when other member submit expense the managerID will be user B
Admin: Enable new rule to prevent self-approvals "Prevent self-approvals", it will block us from submit/approve the expense if the expense is from user B
B: Submit new expense and open the expense, the submit button inside report header will be disabled because we enable the "Prevent self-approvals" option inside the Rules page
Admin: Inside the approval workflow, change the approval to another user (C)
B: The submit/approve button become clickable because the approval is not equal to submitter
B: If we go offline mode, then submit the expense the approve button will show because this check return true
It's because the expense manager id is equal to the current account id (B), it's because after the admin change the approver inside the approval workflow to another user C, the BE doesn't update the managerID
So if we go online mode the BE returns the correct managerID (user C) because inside the params we pass the correct managerID (user C)
and we can also see inside the report header nextstep message returning the correct approval name because we're getting the approval account id from the policy instead of using the managerID
changed the title [-]Web - Header - Approve button appears briefly when it shouldn't[/-][+][$250] Web - Header - Approve button appears briefly when it shouldn't[/+]on Nov 17, 2024
Edited by proposal-police: This proposal was edited at 2024-11-21 03:23:38 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When clicking the submit button, the approve button briefly appears.
What is the root cause of that problem?
If the approval workflow is set as: User A is assigned as both the submitter and approver.
Then when user A submitting an expense, BE will set the managerID of the expense report to user A's accountID.
Then if we change the approval workflow so that the user A is no longer the approver. Here, BE does not update the expense report's managerID, it is still user A's accountID.
As a result, when user A calls submitReport, we change the expense report's stateNum and statusNum:
@daledah What do you think if we always set the first approver ID to managerID when submitting a report? Another question why do we need to revert the managerID in the failureData?
changed the title [-][$250] Web - Header - Approve button appears briefly when it shouldn't[/-][+][HOLD for payment 2024-12-16] [$250] Web - Header - Approve button appears briefly when it shouldn't[/+]on Dec 9, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.72-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@DylanDylann@jliexpensify@DylanDylann The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Admin create a WS and add employee A and B
Admin enable workflow and rules
Go to workflow, add a workflow with use A as both submitter and approver
Go to the "Rules" section and enable "Prevent Self Approval."
Test:
User A go to the WS chat, and create an expense.
Open the expense preview and observe that the submit button is disabled.
Switch to the admin account and go to the "Workflows" section to change the approver from User A to the other user.
Return to User A's account, observe that the submit button is now enabled, and click on it.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
melvin-bot commentedon Nov 16, 2024
Triggered auto assignment to @jliexpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.NJ-2020 commentedon Nov 17, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Web - Header - Approve button appears briefly when it shouldn't
What is the root cause of that problem?
For example we have 3 users: A (admin), B, and C
Admin: Add new approval workflow (from B and approval B), the BE will set the
managerIDfor the approval to B because the approval is BE so when other member submit expense the managerID will be user BAdmin: Enable new rule to prevent self-approvals "Prevent self-approvals", it will block us from submit/approve the expense if the expense is from user B
B: Submit new expense and open the expense, the submit button inside report header will be disabled because we enable the "Prevent self-approvals" option inside the Rules page
Admin: Inside the approval workflow, change the approval to another user (C)
B: The submit/approve button become clickable because the approval is not equal to submitter
B: If we go offline mode, then submit the expense the approve button will show because this check return true
App/src/libs/actions/IOU.ts
Line 6739 in 9774032
App/src/libs/actions/IOU.ts
Line 6757 in 9774032
It's because the expense manager id is equal to the current account id (B), it's because after the admin change the approver inside the approval workflow to another user C, the BE doesn't update the managerID
So if we go online mode the BE returns the correct managerID (user C) because inside the params we pass the correct managerID (user C)
App/src/libs/actions/IOU.ts
Lines 7235 to 7241 in 9774032
and we can also see inside the report header nextstep message returning the correct approval name because we're getting the approval account id from the policy instead of using the managerID
App/src/libs/actions/IOU.ts
Lines 6846 to 6860 in 9774032
What changes do you think we should make in order to solve the problem?
There are several options to solve this issue
managerIDvalueApp/src/pages/home/ReportScreen.tsx
Line 188 in 9774032
we can do the following:
canApproveIOUfunction we can use the approval account id from the policy instead of using the managerIDWhat alternative solutions did you explore? (Optional)
instead of using
PolicyUtils.getSubmitToAccountIDwe can do the similar logic like what we do hereApp/src/libs/actions/IOU.ts
Lines 6846 to 6860 in 9774032
jliexpensify commentedon Nov 17, 2024
I can reproduce this one, I think it'll be a #quality issue?
[-]Web - Header - Approve button appears briefly when it shouldn't[/-][+][$250] Web - Header - Approve button appears briefly when it shouldn't[/+]melvin-bot commentedon Nov 17, 2024
Job added to Upwork: https://www.upwork.com/jobs/~021858267603397515787
melvin-bot commentedon Nov 17, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (
External)daledah commentedon Nov 18, 2024
Edited by proposal-police: This proposal was edited at 2024-11-21 03:23:38 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When clicking the submit button, the approve button briefly appears.
What is the root cause of that problem?
If the approval workflow is set as: User A is assigned as both the submitter and approver.
Then when user A submitting an expense, BE will set the
managerIDof the expense report touser A's accountID.Then if we change the approval workflow so that the user A is no longer the approver. Here, BE does not update the expense report's
managerID, it is stilluser A's accountID.As a result, when user A calls
submitReport, we change the expense report'sstateNumandstatusNum:App/src/libs/actions/IOU.ts
Lines 7148 to 7149 in 9774032
, so the approve button is still displayed optimistically with the disable state because the
shouldShowApproveButton:App/src/components/ReportActionItem/ReportPreview.tsx
Line 340 in 9774032
is
truebutshouldDisableApproveButton:App/src/components/ReportActionItem/ReportPreview.tsx
Line 342 in 9774032
is
false, until the BE returns the correctmanagerID.What changes do you think we should make in order to solve the problem?
and then revert the
managerIDvalue infailureData.should be fixed in BE side as well.
What alternative solutions did you explore? (Optional)
We also can set managerID to approvalChain[0] when submitting reports
DylanDylann commentedon Nov 21, 2024
@daledah What do you think if we always set the first approver ID to managerID when submitting a report? Another question why do we need to revert the managerID in the failureData?
18 remaining items
[-][$250] Web - Header - Approve button appears briefly when it shouldn't[/-][+][HOLD for payment 2024-12-16] [$250] Web - Header - Approve button appears briefly when it shouldn't[/+]melvin-bot commentedon Dec 9, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Dec 9, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.72-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2024-12-16. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Dec 9, 2024
@DylanDylann @jliexpensify @DylanDylann The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
jliexpensify commentedon Dec 9, 2024
Payment Summary
Upwork job
DylanDylann commentedon Dec 10, 2024
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] 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: [NoQA] Feat: Add submit action #28947 (comment)
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Admin create a WS and add employee A and B
Admin enable workflow and rules
Go to workflow, add a workflow with use A as both submitter and approver
Go to the "Rules" section and enable "Prevent Self Approval."
Test:
Do we agree 👍 or 👎
jliexpensify commentedon Dec 16, 2024
Paid and job closed!