Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.58k stars 2.92k forks source link

[HOLD for payment 2023-10-16] [$500] Approved requests shouldn't have a `delete` option #26419

Closed JmillsExpensify closed 1 year ago

JmillsExpensify commented 1 year ago

While we've already implemented logic preventing paid requests from being deleted, the same isn't true for approved requests, which we've just added. Accordingly, let's remove the Delete request option from the three dot overflow menu anytime a request has been approved.

Here's mock for clarity. Notice how I've removed the Delete request option. image

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01bd5a594a7f989566
  • Upwork Job ID: 1697326804261687296
  • Last Price Increase: 2023-08-31
  • Automatic offers:
    • cubuspl42 | Reviewer | 26523887
    • Pujan92 | Contributor | 26523889
melvin-bot[bot] commented 1 year ago

Triggered auto assignment to @NicMendonca (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details.

jeet-dhandha commented 1 year ago

Proposal

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

What is the root cause of that problem?

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

https://github.com/Expensify/App/blob/c9c1f47442546f2254ede5c3fab99246dd381e94/src/components/MoneyRequestHeader.js#L60

const isApproved = ReportUtils.isReportApproved(moneyRequestReport);

https://github.com/Expensify/App/blob/c9c1f47442546f2254ede5c3fab99246dd381e94/src/components/MoneyRequestHeader.js#L81-L84

shouldShowThreeDotsButton={isActionOwner && !isSettled && !isApproved}

https://github.com/Expensify/App/blob/7c13734d048c2b8e61f33c4e24bdc4f42d782952/src/libs/ReportUtils.js#L749

const report = getReport(reportID);
if (isActionOwner && ReportActionsUtils.isMoneyRequestAction(reportAction) && !isSettled(reportAction.originalMessage.IOUReportID) && !isReportApproved(report)) {

What alternative solutions did you explore? (Optional)

For Ref of which options are available https://github.com/Expensify/App/blob/c9c1f47442546f2254ede5c3fab99246dd381e94/src/components/MoneyRequestHeader.js#L85-L91
threeDotsMenuItems={[
    ...(!isApproved
        ? [
                {
                    icon: Expensicons.Trashcan,
                    text: props.translate('reportActionContextMenu.deleteAction', {action: parentReportAction}),
                    onSelected: deleteTransaction,
                },
            ]
        : []),
    ...restOptions,
]}

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

Current assignees @JmillsExpensify and @NicMendonca are eligible for the External assigner, not assigning anyone new.

melvin-bot[bot] commented 1 year ago

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

Pujan92 commented 1 year ago

Proposal

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

Approved requests show a delete option which should not be available

What is the root cause of that problem?

Currently, we do not have applied conditions to not show delete action in the report header as well in the context menu.

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

I am assuming when the request is settled up, it also gets approved indirectly(which means the approved fields are set to the correct status). Consider adding a check isReportApproved by using ReportUtils.isReportApproved(report) below places

  1. https://github.com/Expensify/App/blob/b226893b81f1e160bef4a6821cee19c8a03bcd24/src/components/MoneyRequestHeader.js#L84 && !isReportApproved

  2. Add conditions for the context menu actions also to avoid showing the delete option https://github.com/Expensify/App/blob/b226893b81f1e160bef4a6821cee19c8a03bcd24/src/pages/home/report/ContextMenu/ContextMenuActions.js#L310-L320

https://github.com/Expensify/App/blob/b226893b81f1e160bef4a6821cee19c8a03bcd24/src/libs/ReportUtils.js#L749

const report = getReport(reportAction.originalMessage.IOUReportID)
&& !isReportApproved(report)

https://github.com/Expensify/App/blob/b226893b81f1e160bef4a6821cee19c8a03bcd24/src/libs/ReportUtils.js#L756

(ReportActionsUtils.isMoneyRequestAction(reportAction) && isReportApproved(report)) ||

At the moment I am not able to test as not having the approved feature/permission for my account.

cubuspl42 commented 1 year ago

@Pujan92 Isn't this feature behind a beta, like most other features? Typically it's enough to manually opt-in by returning true from an appropriate function in Permissions.js.

JmillsExpensify commented 1 year ago

@Pujan92 Were you able to figure out the beta consideration?

cubuspl42 commented 1 year ago

@jeet-dhandha Did you have any issues with testing the proposed solution?

@Pujan92 Also, would you sum up briefly the difference between your proposal and the earlier one?

jeet-dhandha commented 1 year ago

No i didn't had any issues.

Pujan92 commented 1 year ago

@cubuspl42 @JmillsExpensify actually approve button only shows for the corporate policy with manager account id. Now, I am making it true directly and able to test.

https://github.com/Expensify/App/blob/9701fbe5ec24bf5031da390075b2a9fb125b3ce3/src/components/MoneyReportHeader.js#L75-L80

@Pujan92 Also, would you sum up briefly the difference between your proposal and https://github.com/Expensify/App/issues/26419#issuecomment-1701577670?

I see that the earlier proposal has been updated laterwards and now it looks quite similar.

jeet-dhandha commented 1 year ago

@cubuspl42 Let @Pujan92 have this one 👍 .

jeet-dhandha commented 1 year ago

I wanted know how we can allow CORPORATE type Workspace/

Pujan92 commented 1 year ago

I wanted know how we can allow CORPORATE type Workspace/

I don't think we have an option for creating corporate policy.

Pujan92 commented 1 year ago

Now, I am making it true directly and able to test.

Seems incorrect permission or data which we passed to ApproveMoneyRequest api call closing the report(in the backend checks) and make it archived.

https://github.com/Expensify/App/assets/14358475/914b2cc1-7f89-4d75-ae6c-52467f19c5c9

Considering that I think it can be tested correctly only on corporate policy.

cubuspl42 commented 1 year ago

Both proposals, in their final form, looked similar and contained convincing root cause analysis and solution plan. Honoring the suggestion by @jeet-dhandha, I say we go with @Pujan92 proposal.

At the implementation phase, we'll need to ensure that we have appropriate permissions and capabilities to test the solution thoroughly.

C+ reviewed 🎀 👀 🎀

melvin-bot[bot] commented 1 year ago

Triggered auto assignment to @Julesssss, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

cubuspl42 commented 1 year ago

@Julesssss Would you take a look at the discussion above, and help us with figuring out what permissions or other backend state we need to test this solution? How can we put our hands on a "corporate policy"?

To be honest, this is my first encounter with such entity.

Julesssss commented 1 year ago

Would you take a look at the discussion above, and help us with figuring out what permissions or other backend state we need to test this solution? How can we put our hands on a "corporate policy"?

I'm pretty sure this is just a request made to a workspace. The workspace admin is the manager:

Screenshot 2023-09-04 at 13 12 06
cubuspl42 commented 1 year ago

@Pujan92

Considering that I think it can be tested correctly only on corporate policy.

Would you confront the assumption above with tips by @Julesssss?

Pujan92 commented 1 year ago

@cubuspl42 With the tips given by @Julesssss and by commenting below condition I am able to see the Approve button on the admin side. https://github.com/Expensify/App/blob/1e0a249ba030b779d749ba07774a896b0f2c931f/src/components/MoneyReportHeader.js#L76-L78

On approving the request the report has been archived and also on the admin side seeing the crash, is archiving the report intentional in corporate policy too?

Requestor Manager/Admin
Screenshot 2023-09-04 at 22 18 38 Screenshot 2023-09-04 at 22 18 46

I think it should set the statusNum to 3 which is approved status instead it set to 2.

https://github.com/Expensify/App/blob/1e0a249ba030b779d749ba07774a896b0f2c931f/src/CONST.ts#L578-L582

cubuspl42 commented 1 year ago

On approving the request the report has been archived and also on the admin side seeing the crash, is archiving the report intentional in corporate policy too?

I don't know the answer.

@Julesssss @JmillsExpensify Do you have any idea?

Julesssss commented 1 year ago

We shouldn't be archiving a report on approval, discussing with the team currently...

Julesssss commented 1 year ago

is archiving the report intentional in corporate policy too?

Hey @Pujan92 can you please create a bug for this? (to ensure you claim the bounty).

Pujan92 commented 1 year ago

is archiving the report intentional in corporate policy too?

Hey @Pujan92 can you please create a bug for this? (to ensure you claim the bounty).

Created, https://expensify.slack.com/archives/C049HHMV9SM/p1693912029208039

Julesssss commented 1 year ago

Okay, so with that being treated as a separate issue I think we're good to move forward with @Pujan92's proposal.

melvin-bot[bot] commented 1 year ago

📣 @cubuspl42 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] commented 1 year ago

📣 @Pujan92 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻 Keep in mind: Code of Conduct | Contributing 📖

Pujan92 commented 1 year ago

@Julesssss The condition for solving this issue depends on the report status, so we can't test this change until the report not gets archived and is in the approved state. Can we hold this issue until other issue of approving report correctly takes place?

Julesssss commented 1 year ago

Ah right. Sure

Julesssss commented 1 year ago

Issue on hold

JmillsExpensify commented 1 year ago

Can someone clarify the issue/PR we're holding on please?

Julesssss commented 1 year ago

Can someone clarify the issue/PR we're holding on please?

https://expensify.slack.com/archives/C049HHMV9SM/p1693912029208039

Applause is unable to reproduce, can anyone spot the missing step that they might need to configure the correct env? They should be included in all betas already 😕

Pujan92 commented 1 year ago

@Julesssss it is shown only for the Corporate Policy as per this comment snippet. In the dev we just commented out the condition to test based on earlier discussion.

Julesssss commented 1 year ago

But QA should be able to reproduce it then? 😕

Pujan92 commented 1 year ago

But QA should be able to reproduce it then? 😕

Do they create a new corporate policy? If yes then I think can be reproducible for them and able to see approve button for admin.

JmillsExpensify commented 1 year ago

It's impossible to create a new corporate policy. This only applies to the one policy that we've added for Teachers Unite! Basically something that only Expensify can/has done.

Pujan92 commented 1 year ago

Ok, in that case I am a member of the Teachers Unite and tried splitting the bill and currently I am seeing a request. To test my solution of not providing the delete action option after approval, the admin/manager needs to approve the request. Is that something we can do?

Screenshot 2023-09-13 at 17 31 15
melvin-bot[bot] commented 1 year ago

@JmillsExpensify, @cubuspl42, @Julesssss, @Pujan92 Eep! 4 days overdue now. Issues have feelings too...

JmillsExpensify commented 1 year ago

Sorry for the delay, don't hesitate to reach out via DM on NewDot if you don't get a fast response. I can go in and approve your request now.

cubuspl42 commented 1 year ago

Okey, this issue definitely needs an update. Formally, we're holding on https://github.com/Expensify/App/issues/27242, but that one is closed because it's not reproducible (?).

JmillsExpensify commented 1 year ago

I think we should take this issue off hold as soon as I approve the request shown in the screenshot above.

JmillsExpensify commented 1 year ago

@Pujan92 Can you try a fresh one in USD? I'm not seeing an approve button and I'm betting it's because you've requested an amount that is less than a dollar.

Screenshot 2023-09-19 at 18 21 44
Pujan92 commented 1 year ago

@JmillsExpensify I just made a new request of greater than 1 USD and hope now approve button is visible to you.

JmillsExpensify commented 1 year ago

Ok great. Looking

JmillsExpensify commented 1 year ago

Ok I checked the Onyx for this report. You've set your "principal" and approver as a@a.com. I'm using the volunteer@expensify.com account, but that's only used for payment. So accordingly, I'm not seeing an approve button since the principal/approver you set is a@a.com. Does that make sense?

JmillsExpensify commented 1 year ago

Based on that, I think you have the tools you need to test this yourself. Just make sure that when you sign up using the Teachers Unite form that you have access to both the "teacher" and "principal" emails. At that point, you'll be able to verify your solution works.

Pujan92 commented 1 year ago

Thanks @JmillsExpensify , I got your point and I believe I can test with having a known "principal" email bcoz it is set as a manager so surely the approve button should be visible in the report.

Pujan92 commented 1 year ago

@cubuspl42 PR is ready for review!

JmillsExpensify commented 1 year ago

Thanks @JmillsExpensify , I got your point and I believe I can test with having a known "principal" email bcoz it is set as a manager so surely the approve button should be visible in the report.

Yes exactly. Thank you!