Skip to content
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

[Collect approvers] [$1000] Expense - Error appears when admin tries to pay a request without having approved it #34857

Closed
1 of 6 tasks
lanitochka17 opened this issue Jan 20, 2024 · 55 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 20, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.28-0
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:

Action Performed:

Pre-requisite: user must have created a collect workspace and
added a BA. With an employee account, create a request and submit it

  1. As the admin on ND, navigate to the workspace chat with the employee
  2. Click on the expense to go to report page
  3. Click on "Pay with Expensify"

Expected Result:

It should be possible to pay the expense without problems
.

Actual Result:

Admin can not pay the expense without approving it first, an error message appears
Unexpected error, please try again later
An unexpected error ocurred. Please try again later

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6348754_1705769462013.bandicam_2024-01-19_18-11-16-153.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0130f77ed31ac8823b
  • Upwork Job ID: 1748765068058488832
  • Last Price Increase: 2024-04-06
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 20, 2024
@melvin-bot melvin-bot bot changed the title Expense - Error appears when admin tries to pay a request without having approved it [$500] Expense - Error appears when admin tries to pay a request without having approved it Jan 20, 2024
Copy link

melvin-bot bot commented Jan 20, 2024

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

Copy link

melvin-bot bot commented Jan 20, 2024

Job added to Upwork: https://www.upwork.com/jobs/~0130f77ed31ac8823b

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 20, 2024
Copy link

melvin-bot bot commented Jan 20, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External)

@lanitochka17
Copy link
Author

We think that this bug might be related to #wave7.
CC @RachCHopkins

@promisingcoder
Copy link

promisingcoder commented Jan 22, 2024

Proposal
Problem Statement:
In the application, an admin cannot pay an expense without first approving it. This issue arises during the execution of the confirm function in the MoneyRequestConfirmationList component. The function terminates early if the selectedParticipants array is empty, which is often the case for admin users who are processing the payment but are not participants in the traditional sense.

Root Cause Analysis:
The root cause lies in the conditional check within the confirm function:

if (_.isEmpty(selectedParticipants)) {
return;
}
This condition is designed to prevent the progression of the payment process if no participants are selected. However, in the context of an admin user, this check is too restrictive, as the admin is not a participant but still needs to initiate the payment.

Proposed Solution:
The solution involves modifying the conditional check to accommodate admin users. This can be done by introducing an additional state or prop to indicate whether the current user is an admin. Based on this, the function can bypass the participant check for admins.

Updated Code:

Introduce an Admin Flag: Add a new state or prop to the component to indicate whether the user is an admin. For simplicity, let's assume a prop isAdmin is passed to the component.

Modify the Conditional Check:
Update the condition in the confirm function to bypass the participant check if the user is an admin.

const confirm = useCallback(
(paymentMethod) => {
if (!props.isAdmin && _.isEmpty(selectedParticipants)) {
return;
}

    // ...rest of the function
},
[
    // ...dependencies
],

);
Rationale:
This modification ensures that the payment process is not unnecessarily halted for admin users. By checking the isAdmin flag, the function can appropriately handle scenarios where an admin needs to make a payment without being a participant. This change is targeted and should not cause regressions in other parts of the application, as it specifically addresses the admin scenario. Additionally, it aligns with the general expectation that admins have different permissions and capabilities compared to regular users.

Testing Considerations:
Post-implementation, thorough testing is required to ensure the payment process works correctly for both admin and non-admin users. This includes testing various scenarios and ensuring that the application's behavior remains consistent and as expected.

@melvin-bot melvin-bot bot added the Overdue label Jan 24, 2024
@abdulrahuman5196
Copy link
Contributor

Will check this issue in my morning.

@melvin-bot melvin-bot bot removed the Overdue label Jan 25, 2024
Copy link

melvin-bot bot commented Jan 27, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@mallenexpensify
Copy link
Contributor

@abdulrahuman5196 please review the above. @RachCHopkins I agree these seems to fit with Wave 7 so I've added to the project there. Let me know if you disagree.

@abdulrahuman5196
Copy link
Contributor

Reviewing now

@abdulrahuman5196
Copy link
Contributor

@promisingcoder Could you kindly update the proposal as per the proposal template - https://raw.githubusercontent.com/Expensify/App/main/contributingGuides/PROPOSAL_TEMPLATE.md

Meanwhile I did a high level check. Could you kindly provide more information on how MoneyRequestConfirmationList is related to the action taken on the SettlementButton ?

@abdulrahuman5196
Copy link
Contributor

@mallenexpensify Could you kindly provide information on how to create this pre-requisite?

Pre-requisite: user must have created a collect workspace and
added a BA. With an employee account, create a request and submit it

@promisingcoder
Copy link

@abdulrahuman5196
MoneyRequestConfirmationList: This is a list that shows all the participants involved in a money request. It also handles the confirmation of the request.

SettlementButton: This is a button that, when pressed, triggers the payment process. It's used within the MoneyRequestConfirmationList component.

The action of pressing the SettlementButton triggers a function called confirm in the MoneyRequestConfirmationList component. This function checks if there are any selected participants and if a payment method is provided. If these conditions are met, it sets a state called didConfirm to true and calls another function, onSendMoney, with the selected payment method as an argument.

The proposal suggests modifying the confirm function to accommodate admin users who need to confirm payments but are not participants in the traditional sense. Currently, the confirm function terminates early if the selectedParticipants array is empty, which is often the case for admin users. By introducing an additional check for admin users in the confirm function, the SettlementButton can successfully trigger the payment process even when the user is an admin.

So, in simple terms, the SettlementButton starts the action that the confirm function in the MoneyRequestConfirmationList component carries out. The proposed changes aim to make sure that this process works correctly for all users, including admins.

@mallenexpensify
Copy link
Contributor

Pre-requisite: user must have created a collect workspace and
added a BA. With an employee account, create a request and submit it

@abdulrahuman5196 , most of that can be done view OldDot, expensify.com. The part I'm unsure about is 'added a BA` (which I'm assuming is Bank Account) Ah ha, looks like this should work
https://expensify.slack.com/archives/C01GTK53T8Q/p1706551410056249?thread_ts=1706541901.752409&cid=C01GTK53T8Q

@melvin-bot melvin-bot bot added the Overdue label Feb 1, 2024
@abdulrahuman5196
Copy link
Contributor

Will check on the old dot setup in my morning

@melvin-bot melvin-bot bot removed the Overdue label Feb 1, 2024
Copy link

melvin-bot bot commented Feb 3, 2024

@mallenexpensify @abdulrahuman5196 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

Copy link

melvin-bot bot commented Feb 3, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Feb 5, 2024
@abdulrahuman5196
Copy link
Contributor

Still having trouble with setup, will try today or reach out in slack

@melvin-bot melvin-bot bot removed the Overdue label Feb 5, 2024
@trjExpensify
Copy link
Contributor

Why's this one held still? The linked issue is ready for payment tomorrow?

@mallenexpensify mallenexpensify added the retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause label Mar 15, 2024
@mallenexpensify
Copy link
Contributor

Unsure @trjExpensify . My process for held issues is to hover over the link to see if it's open or closed. Musta misread it for this one.

Taking off hold, Added Retest-weekly

@mallenexpensify mallenexpensify changed the title [HOLD #34951] [Collect approvers] [$1000] Expense - Error appears when admin tries to pay a request without having approved it [Collect approvers] [$1000] Expense - Error appears when admin tries to pay a request without having approved it Mar 15, 2024
@mallenexpensify mallenexpensify added Daily KSv2 and removed Weekly KSv2 labels Mar 15, 2024
@melvin-bot melvin-bot bot added the Overdue label Mar 18, 2024
Copy link

melvin-bot bot commented Mar 19, 2024

@mallenexpensify, @abdulrahuman5196 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@mallenexpensify
Copy link
Contributor

Waiting on the retest.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Mar 20, 2024
@mallenexpensify
Copy link
Contributor

Waiting on retest

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Mar 27, 2024
@abdulrahuman5196
Copy link
Contributor

waiting on retest

@melvin-bot melvin-bot bot removed the Overdue label Apr 1, 2024
@mvtglobally
Copy link

Issue is reproducible during KI retests.

1712169548259.cc.mp4

@melvin-bot melvin-bot bot added the Overdue label Apr 4, 2024
@mvtglobally mvtglobally removed the retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause label Apr 4, 2024
@mallenexpensify mallenexpensify added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 5, 2024
@mallenexpensify
Copy link
Contributor

mallenexpensify commented Apr 6, 2024

Just tried to reproduce and can't. @abdulrahuman5196 , can you please try? I could be holding something wrong but I def have a bank account connected on a collect workspace.
https://github.com/Expensify/App/assets/22508304/fd6888f4-e2cc-4f24-b3f5-8cb3e3e1f8a4

@melvin-bot melvin-bot bot removed the Overdue label Apr 6, 2024
Copy link

melvin-bot bot commented Apr 6, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Apr 8, 2024
Copy link

melvin-bot bot commented Apr 9, 2024

@mallenexpensify, @abdulrahuman5196 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@abdulrahuman5196
Copy link
Contributor

Issue is reproducible during KI retests.
1712169548259.cc.mp4

Actually, Don't understand this reproduced video.
I don't see any errors here? @mvtglobally

@melvin-bot melvin-bot bot removed the Overdue label Apr 9, 2024
@mallenexpensify
Copy link
Contributor

Unable to reproduce again. This issue is a few months old and we've had many changes. If we encounter it again, someone can create a new issue with repro steps.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
No open projects
Archived in project
Development

No branches or pull requests

8 participants