App icon indicating copy to clipboard operation
App copied to clipboard

[$500] Approve button not displayed by default in the dropdown

Open kavimuru opened this issue 1 year ago โ€ข 31 comments

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.54-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: https://expensify.testrail.io/index.php?/tests/view/4433593 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:

  1. As an employee submit an expense report to workspace chat
  2. Log in as the Admin of the workspace
  3. Navigate to the workspace chat of the employee who submitted the report
  4. Observe the button in the report preview

Expected Result:

Approve should be appearing by default in the button which has dropdown

Actual Result:

Pay Elsewhere is displayed by default, user needs to click on drop down menu and then select Approve.

Workaround:

unknown

Platforms:

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

  • [ ] Android: Native
  • [ ] Android: mWeb Chrome
  • [ ] iOS: Native
  • [ ] iOS: mWeb Safari
  • [x] MacOS: Chrome / Safari
  • [ ] MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/43996225/d39eb4fa-cca6-4d53-88c1-0bb57207fccd

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0167219d0cf776ee3b
  • Upwork Job ID: 1770252974466375680
  • Last Price Increase: 2024-03-20
Issue OwnerCurrent Issue Owner: @mallenexpensify

kavimuru avatar Mar 19 '24 16:03 kavimuru

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

melvin-bot[bot] avatar Mar 19 '24 16:03 melvin-bot[bot]

We think this bug might be related to #wave-collect - Release 1

kavimuru avatar Mar 19 '24 16:03 kavimuru

@mallenexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors.

kavimuru avatar Mar 19 '24 16:03 kavimuru

Proposal

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

Pay Elsewhere is displayed by default, user needs to click on drop down menu and then select Approve.

What is the root cause of that problem?

We're pushing approve button at the end of the list

https://github.com/Expensify/App/blob/71e3aa4eb3be90eeadd27260dfb87a3ff67185be/src/components/SettlementButton.tsx#L189-L191

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

We should add approveButtonOption to the beginning of buttonOptions

 if (shouldShowApproveButton) {
            buttonOptions.unshift(approveButtonOption);
        }

What alternative solutions did you explore? (Optional)

NA

Result

https://github.com/Expensify/App/assets/113963320/c461ebe3-9643-4e72-aa10-230e842ee2eb

tienifr avatar Mar 19 '24 16:03 tienifr

Proposal

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

Approve button not displayed by default in the dropdown.

What is the root cause of that problem?

Approve button is pushed at end of the list. Also, payment options are being sorted.

https://github.com/Expensify/App/blob/71e3aa4eb3be90eeadd27260dfb87a3ff67185be/src/components/SettlementButton.tsx#L180-L196

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

After the whole logic is done, push approve button at beginning if it needs to be shown.

const paymentMethod = nvpLastPaymentMethod?.[policyID] ?? '';
if (canUseWallet) {
    buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]);
}
if (isExpenseReport && shouldShowPaywithExpensifyOption) {
    buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.VBBA]);
}
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]);

// Put the preferred payment method to the front of the array, so it's shown as default if approve button is not to be shown.
if (paymentMethod) {
    return buttonOptions.sort((method) => (method.value === paymentMethod ? -1 : 0));
}

if (shouldShowApproveButton) {
    buttonOptions.unshift(approveButtonOption);
}

ShridharGoel avatar Mar 19 '24 16:03 ShridharGoel

Proposal

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

Approve button not displayed by default in the dropdown

What is the root cause of that problem?

We push the button options and sort the option based on paymentMethod, this will always sort the option regardless of the sequence we put the buttons in.

https://github.com/Expensify/App/blob/71e3aa4eb3be90eeadd27260dfb87a3ff67185be/src/components/SettlementButton.tsx#L194-L195

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

First, we need to put the approve button at the top of the button list:

+         if (shouldShowApproveButton) {
+            buttonOptions.push(approveButtonOption);
+        }
        if (canUseWallet) {
            buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]);
        }
        ........

Then update the condition such that it will not sort the order if shouldShowApproveButton is set to true, then it will by default return the unsorted order of options:


-        if (paymentMethod) {
+        if (paymentMethod && !shouldShowApproveButton) {
            return buttonOptions.sort((method) => (method.value === paymentMethod ? -1 : 0));
        }

What alternative solutions did you explore? (Optional)

N/A

allgandalf avatar Mar 19 '24 17:03 allgandalf

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

melvin-bot[bot] avatar Mar 20 '24 00:03 melvin-bot[bot]

Triggered auto assignment to Contributor Plus for review of internal employee PR - @mananjadhav (Internal)

melvin-bot[bot] avatar Mar 20 '24 00:03 melvin-bot[bot]

Unable to reproduce, the steps in the OP aren't the most clear to me either. @mananjadhav can you attempt reproduction? If you're able to, can you propose the steps and I'll update the OP? Thx

mallenexpensify avatar Mar 20 '24 00:03 mallenexpensify

I am unable to send/request money on staging for my collect policy. It is asking to update the billing info. Meanwhile, I just manually enabled the condition and I can Approve is in the dropdown.

image

mananjadhav avatar Mar 20 '24 15:03 mananjadhav

If we plan to go ahead, I think @tienifr's proposal looks good to me. All the proposals have the correct RCA and on similar lines.

๐ŸŽ€ ๐Ÿ‘€ ๐ŸŽ€ C+ reviewed

mananjadhav avatar Mar 20 '24 15:03 mananjadhav

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

melvin-bot[bot] avatar Mar 20 '24 15:03 melvin-bot[bot]

I managed to reproduce it. However, after checking the solutions, I am a bit confused about the expected behavior when there is a preferred payment method. @mallenexpensify Should we always show Approve first or should the preferred payment method go first if there is any? It would be great if you can double check before assigning a proposal.

pecanoro avatar Mar 20 '24 16:03 pecanoro

Current assignee @mananjadhav is eligible for the External assigner, not assigning anyone new.

melvin-bot[bot] avatar Mar 20 '24 16:03 melvin-bot[bot]

I managed to reproduce it. However, after checking the solutions, I am a bit confused about the expected behavior when there is a preferred payment method. @mallenexpensify Should we always show Approve first or should the preferred payment method go first if there is any? It would be great if you can double check before assigning a proposal.

@pecanoro , I got this thought too and hence in my proposal, i put a condition:


-        if (paymentMethod) {
+        if (paymentMethod && !shouldShowApproveButton) {
           return buttonOptions.sort((method) => (method.value === paymentMethod ? -1 : 0));
       }

This would solve the issue of the preferred payments as well :)

So when shouldShowApproveButton if false, i.e. the report has been approved, then we automatically push the preferred payment method to the top,

allgandalf avatar Mar 20 '24 16:03 allgandalf

@mananjadhav Can you check my proposal once? I think the unshift should be done after sorting is complete, which will ensure that Approve is always at top.

ShridharGoel avatar Mar 20 '24 17:03 ShridharGoel

Else it doesn't make much sense if sorting is done after approve is added at top, because it will then again get shifted.

ShridharGoel avatar Mar 20 '24 17:03 ShridharGoel

As mentioned in

https://github.com/Expensify/App/blob/71e3aa4eb3be90eeadd27260dfb87a3ff67185be/src/components/SettlementButton.tsx#L193-L196

I think we want to show the preferred payment method first if there is. Otherwise the approve button is shown as the OP expectation.

But we still need to hear what the final expectation is

tienifr avatar Mar 21 '24 11:03 tienifr

We can discuss the proposals once @mallenexpensify can get clarification on what's the expected order of these buttons

pecanoro avatar Mar 21 '24 14:03 pecanoro

bump @mallenexpensify

allgandalf avatar Mar 22 '24 23:03 allgandalf

I am unable to send/request money on staging for my collect policy. It is asking to update the billing info. Meanwhile, I just manually enabled the condition and I can Approve is in the dropdown.

image

@mananjadhav How and where did you manually enable the condition to send/request money on collect policies when there was an error asking you to update your billing info?

Victor-Nyagudi avatar Mar 24 '24 12:03 Victor-Nyagudi

I am a bit confused about the expected behavior when there is a preferred payment method

I am also a lil confused. If there is a preferred payment setup in Expensify then I'd imagine that the Approve button would show. If there's not, I can see reasoning for Pay Elsewhere cuz approving would do anything.

So... back to the OP, do we know if a bank account or preferred payment method is setup for the admin or user?

mallenexpensify avatar Mar 25 '24 00:03 mallenexpensify

@mallenexpensify Could you ask in product was the desired behaviour? I think neither of us is sure about the expected one

pecanoro avatar Mar 26 '24 19:03 pecanoro

Checking on in #qa to see if admin and/or user have bank accounts setup, since I think that would affect expected behaviour https://expensify.slack.com/archives/C9YU7BX5M/p1711498027841129

mallenexpensify avatar Mar 27 '24 00:03 mallenexpensify

From the post in #qa

Neither have bank accounts set up.

I think that's why the expected behaviour isn't to show Approve. We show Pay elsewhere because it's the only way for the user to get paid back. If the default was Approve, then nothing would happen. Right?

mallenexpensify avatar Mar 27 '24 16:03 mallenexpensify

Approve is different from reimburse, a report can be approved a not reimbursed

pecanoro avatar Mar 27 '24 16:03 pecanoro

What do you think of this proposal then @pecanoro , this will sort to most preferred option only when shouldShowApproveButton will become false, otherwise if shouldShowApproveButton is true then it will show the approve at the top !

Also it moves away from the time and space complexity associated with unshift function and is faster than other suggested approaches

allgandalf avatar Mar 27 '24 16:03 allgandalf

Checking in #expensify-open-source https://expensify.slack.com/archives/C01GTK53T8Q/p1711580170798549

mallenexpensify avatar Mar 27 '24 22:03 mallenexpensify

Checking on internally in #qa. Also, added to #wave-collect because it has to do with approving a payment and that'd first be encountered in that project.

mallenexpensify avatar Mar 28 '24 19:03 mallenexpensify

Ok! I got double confirmation that we do want to show Approve @mananjadhav can you review the above and provide feedback? Thx

mallenexpensify avatar Mar 29 '24 22:03 mallenexpensify