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

[Awaiting Payment] Remove "submit expense" from the create menu in reports that can't be edited by the submitter #50734

Closed
garrettmknight opened this issue Oct 14, 2024 · 19 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Internal Requires API changes or must be handled by Expensify staff

Comments

@garrettmknight
Copy link
Contributor

garrettmknight commented Oct 14, 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: N/A
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: @jliexpensify
Slack conversation: https://expensify.enterprise.slack.com/archives/C049HHMV9SM/p1728931883829909?thread_ts=1728667465.791999&channel=C049HHMV9SM&message_ts=1728931883.829909

Action Performed:

I think this is what the behavior is intended to be in this situation:

  1. Consider a workspace with submitter, approver A and approver B
  2. Set approver a as approver A
  3. As submitter, submit expense to the workspace chat. Will be assigned to approver A.
  4. Change approver to approver B
  5. As submitter, open the report and tap the "+" button in the report.

Expected Result:

The submitter should only see the add attachment and assign task.

Actual Result:

The submitter has the "submit expense" option and when they try to use it, it throws an error.

Workaround:

Submit an expense in the workspace chat.

Platforms:

All

Screenshots/Videos

Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021845992378187974958
  • Upwork Job ID: 1845992378187974958
  • Last Price Increase: 2024-10-15
@garrettmknight garrettmknight added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Oct 14, 2024
Copy link

melvin-bot bot commented Oct 14, 2024

Triggered auto assignment to @garrettmknight (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.

@twilight2294
Copy link
Contributor

twilight2294 commented Oct 14, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Remove "submit expense" from the create menu in reports that can't be edited by the submitter

What is the root cause of that problem?

The error in the actual result: The submitter has the "submit expense" option and when they try to use it, it throws an error. occurs because when we change the approver of the current policy and then go back to the report, and resubmit another one the original report's managerID is different from the current submitsTo, that is because we have changed the approver to another member of the policy, this gives us the error as managerID of the current report doesn't match with the submitsTo of the policy, the current report is still submitted to the previous approver.

What changes do you think we should make in order to solve the problem?

According to expected results, we need to hide the submit option, we can do that in canRequestMoney util function here:

function canRequestMoney(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, otherParticipants: number[]): boolean {

We will use getSubmitToAccountID to get the latest submits to of the policy and compare it with the existing reports managerID and if they do not match then we will hide the option to submit expense:

function getSubmitToAccountID(policy: OnyxEntry<Policy>, employeeAccountID: number): number {

So add a new condition to canRequestMoney :

--- a/src/libs/ReportUtils.ts
+++ b/src/libs/ReportUtils.ts
@@ -6687,6 +6687,10 @@ function canRequestMoney(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, o
         return false;
     }
 
+    if(PolicyUtils.getSubmitToAccountID(policy, currentUserAccountID ?? -1) !== report?.managerID){
+        return false
+    }

Result

Screen.Recording.2024-10-15.at.1.50.19.AM.mov

@garrettmknight garrettmknight added the External Added to denote the issue can be worked on by a contributor label Oct 15, 2024
@melvin-bot melvin-bot bot changed the title Remove "submit expense" from the create menu in reports that can't be edited by the submitter [$250] Remove "submit expense" from the create menu in reports that can't be edited by the submitter Oct 15, 2024
Copy link

melvin-bot bot commented Oct 15, 2024

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

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

melvin-bot bot commented Oct 15, 2024

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

@youssef-lr youssef-lr added Internal Requires API changes or must be handled by Expensify staff and removed 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 labels Oct 15, 2024
@youssef-lr
Copy link
Contributor

youssef-lr commented Oct 15, 2024

I'm gonna take this one internal as I'll need to test App changes against backend changes for a related issue.

@youssef-lr youssef-lr changed the title [$250] Remove "submit expense" from the create menu in reports that can't be edited by the submitter Remove "submit expense" from the create menu in reports that can't be edited by the submitter Oct 15, 2024
@muttmuure muttmuure moved this to CRITICAL in [#whatsnext] #quality Oct 15, 2024
@muttmuure muttmuure moved this from CRITICAL to MEDIUM in [#whatsnext] #quality Oct 15, 2024
@twilight2294
Copy link
Contributor

@youssef-lr I have a proposal ready which solves the App issue, can't we test it with my PR ?, you can check the proposal here and since help wanted label was applied, I guess my proposal counts 😄

@youssef-lr
Copy link
Contributor

@twilight294 your proposal is not enough to fully fix the issue, for example, if will break when the approver has a vacation delegate. This will need some backend changes in order to have some data available in App, and I'm going to need to test both backend and frontend while working on this.

@youssef-lr
Copy link
Contributor

I just realized I already had a PR that fixes this #49677, but I need to update it to take into account the delegate.

Copy link

melvin-bot bot commented Oct 18, 2024

@garrettmknight, @youssef-lr, @alitoshmatov Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Oct 18, 2024
@youssef-lr
Copy link
Contributor

Working on it in this PR #49677

Copy link

melvin-bot bot commented Oct 22, 2024

@garrettmknight, @youssef-lr, @alitoshmatov 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

@alitoshmatov
Copy link
Contributor

PR is still in progress #49677

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Oct 23, 2024
@garrettmknight
Copy link
Contributor Author

PR is merged and on staging.

@melvin-bot melvin-bot bot removed the Overdue label Oct 28, 2024
Copy link

melvin-bot bot commented Oct 28, 2024

@garrettmknight @youssef-lr @alitoshmatov this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@muttmuure
Copy link
Contributor

Great work here!

@melvin-bot melvin-bot bot added the Overdue label Oct 30, 2024
@garrettmknight
Copy link
Contributor Author

garrettmknight commented Oct 30, 2024

On prod yesterday!

@melvin-bot melvin-bot bot removed the Overdue label Oct 30, 2024
@garrettmknight garrettmknight added the Awaiting Payment Auto-added when associated PR is deployed to production label Oct 30, 2024
@melvin-bot melvin-bot bot added the Overdue label Nov 1, 2024
@garrettmknight garrettmknight changed the title Remove "submit expense" from the create menu in reports that can't be edited by the submitter [Awaiting Payment] Remove "submit expense" from the create menu in reports that can't be edited by the submitter Nov 4, 2024
@garrettmknight
Copy link
Contributor Author

@mollfpr you get paid somewhere else for your review?

@melvin-bot melvin-bot bot removed the Overdue label Nov 4, 2024
@mollfpr
Copy link
Contributor

mollfpr commented Nov 5, 2024

@garrettmknight I think I'll be paid here #51075

@garrettmknight
Copy link
Contributor Author

Perfect - I'm gonna close this then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Internal Requires API changes or must be handled by Expensify staff
Projects
Status: Done
Development

No branches or pull requests

6 participants