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

[HOLD for payment 2024-10-11] [$250] [Instant Submit] Retain the option to Pay elsewhere on processing/submitted reports when payments get disabled. #49874

Closed
blimpich opened this issue Sep 27, 2024 · 28 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item.

Comments

@blimpich
Copy link
Contributor

blimpich commented Sep 27, 2024

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


Email or phone of affected tester (no customers):
Expensify/Expensify Issue URL: https://github.com/Expensify/Expensify/issues/378376
Issue reported by: @garrettmknight
Slack conversation: https://expensify.slack.com/archives/C036QM0SLJK/p1709825435599569

Action Performed:

  1. Create two new users, A and B
  2. Have user A create a workspace and invite user B to the workspace as an employee
  3. As user B, create an expense on the workspace
  4. As user A, confirm that you can see the expense that user B made but that there is no "Pay with Expensify" and/or "Pay elsewhere" button for the expense
  5. As user A, go to Settings > Workspaces > your_workspace > More features and turn on "Workflows"
  6. Go to Workflows tab and turn on "Make or track payments"
  7. As user B submit an expense to your_workspace
  8. As user A, confirm that you can see the recently made expense and that it says "Pay with Expensify" and/or "Pay elsewhere"
  9. As user A go to Workflows tab and turn off "Make or track payments"
  10. As user A navigate to the newly submitted expense

Expected Result:

There should be an option to "Pay Elsewhere" on the expense for user A.

Actual Result:

There is not option to "Pay Elsewhere".

Workaround:

Turn on payments again, pay the expenses, then turn it off.

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021839794267146442929
  • Upwork Job ID: 1839794267146442929
  • Last Price Increase: 2024-09-27
  • Automatic offers:
    • ZhenjaHorbach | Reviewer | 104203098
    • truph01 | Contributor | 104203100
Issue OwnerCurrent Issue Owner: @garrettmknight
@blimpich blimpich added Daily KSv2 NewFeature Something to build that is a new item. labels Sep 27, 2024
Copy link

melvin-bot bot commented Sep 27, 2024

Triggered auto assignment to @JmillsExpensify (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Sep 27, 2024
Copy link

melvin-bot bot commented Sep 27, 2024

⚠️ It looks like this issue is labelled as a New Feature but not tied to any GitHub Project. Keep in mind that all new features should be tied to GitHub Projects in order to properly track external CAP software time ⚠️

Copy link

melvin-bot bot commented Sep 27, 2024

Triggered auto assignment to Design team member for new feature review - @dubielzyk-expensify (NewFeature)

@blimpich
Copy link
Contributor Author

I don't think this needs design input, its sort of a new feature but more of a work around since we don't have a "mark as close" in new dot feature. Also unassigning @JmillsExpensify since @garrettmknight created the original issue for this so I think it'd be best to keep him as the BZ member on this since he has context.

@blimpich blimpich moved this to HOT PICKS in [#whatsnext] #wave-collect Sep 27, 2024
@blimpich blimpich added the External Added to denote the issue can be worked on by a contributor label Sep 27, 2024
Copy link

melvin-bot bot commented Sep 27, 2024

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

@melvin-bot melvin-bot bot changed the title [Instant Submit] Retain the option to Pay elsewhere on processing/submitted reports when payments get disabled. [$250] [Instant Submit] Retain the option to Pay elsewhere on processing/submitted reports when payments get disabled. Sep 27, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 27, 2024
Copy link

melvin-bot bot commented Sep 27, 2024

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Sep 27, 2024
@blimpich
Copy link
Contributor Author

Note to contributors, I think this should be straightforward, the data for what state a report is in should be in its onyx data. The psuedocode logic we want here is basically this:

if(!policy.settings.shouldAllowPayments && report.statusNum === STATUS_NUM.SUBMITTED) {
	showPaymentElsewhereOption();
}

Please see our constants code for what numbers correspond to what status the report is in.

@blimpich
Copy link
Contributor Author

blimpich commented Sep 27, 2024

And remember, we still want reports that are in the "closed" state, aka expenses that are created while the workspace setting "allow payments" is false, should not show "Pay elsewhere". Its only expenses that are created while "allow payments" is turned on, and then once its turned off we should allow those expenses that are still in the submitted/processing state should be able to be paid elsewhere.

@truph01
Copy link
Contributor

truph01 commented Sep 28, 2024

Edited by proposal-police: This proposal was edited at 2024-09-28 11:35:17 UTC.

Proposal

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

There is not option to "Pay Elsewhere".

What is the root cause of that problem?

  • We don't display the settle button if the policy?.reimbursementChoice is reimburseNo:

    App/src/libs/actions/IOU.ts

    Lines 6941 to 6943 in 71db3f1

    if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
    return false;
    }

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

App/src/libs/actions/IOU.ts

Lines 6941 to 6943 in 71db3f1

if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
return false;
}

    if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
        if (!shouldForceShowOnlyPayElsewhere) {
            return false;
        }
        if (iouReport?.statusNum !== CONST.REPORT.STATUS_NUM.SUBMITTED) {
            return false;
        }
    }

I introduced new shouldForceShowOnlyPayElsewhere param, default value is false.

  • In there, use above function to check should we display only pay else where button:
    const forceShowOnlyPayElsewhere = useMemo(
        () => isPaidAnimationRunning || IOU.canIOUBePaid(iouReport, chatReport, policy, allTransactions, true),
        [isPaidAnimationRunning, iouReport, chatReport, policy, allTransactions],
    );
  • And in there, call isPayer with additional param, shouldForceShowOnlyPayElsewhere:
    const isPayer = ReportUtils.isPayer(
        {
            email: currentUserEmail,
            accountID: userAccountID,
        },
        iouReport,
        shouldForceShowOnlyPayElsewhere,
    );

the isPayer function will be updated as:

if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) {

        if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL || shouldForceShowOnlyPayElsewhere) {
  • Use the above variable in:

{shouldShowSettlementButton && (
<AnimatedSettlementButton

                                {(shouldShowSettlementButton || forceShowOnlyPayElsewhere) && (
                                    <AnimatedSettlementButton
                                        forceShowOnlyPayElsewhere={!shouldShowSettlementButton && forceShowOnlyPayElsewhere}

Now, the AnimatedSettlementButton button can be displayed even if the shouldShowSettlementButton is false. And we pass down forceShowOnlyPayElsewhere to the AnimatedSettlementButton as well.

  • In there, use the above forceShowOnlyPayElsewhere to only display pay elsewhere button:
        if (forceShowOnlyPayElsewhere) {
            return [paymentMethods[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]];
        }

What alternative solutions did you explore? (Optional)

@kushu7
Copy link
Contributor

kushu7 commented Sep 28, 2024

Proposal

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

There is no option to "Pay Elsewhere" when Make or track payments isn't enable.

What is the root cause of that problem?

The reason is we don't show Settlement Button if policy.reimbursementChoice is reimburseNo.
We have early return here:

App/src/libs/actions/IOU.ts

Lines 6941 to 6943 in 71db3f1

if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
return false;
}

and we are not handling reimburseNo case here to determine is current user is isPayer or not.

App/src/libs/ReportUtils.ts

Lines 1700 to 1709 in 71db3f1

if (isPaidGroupPolicy(iouReport)) {
if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES) {
const isReimburser = session?.email === policy?.achAccount?.reimburser;
return (!policy?.achAccount?.reimburser || isReimburser) && (isApproved || isManager);
}
if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) {
return isAdmin && (isApproved || isManager);
}
return false;
}

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

TO solve this problem we have to remove this early return condition here.

App/src/libs/actions/IOU.ts

Lines 6941 to 6943 in 71db3f1

if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
return false;
}

and also update function isPayer to return true for admin or manager of policy.
We can simply update this to handle condition for reimburseNo

App/src/libs/ReportUtils.ts

Lines 1700 to 1709 in 71db3f1

if (isPaidGroupPolicy(iouReport)) {
if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES) {
const isReimburser = session?.email === policy?.achAccount?.reimburser;
return (!policy?.achAccount?.reimburser || isReimburser) && (isApproved || isManager);
}
if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) {
return isAdmin && (isApproved || isManager);
}
return false;
}

by doing this we will have shouldShowPayButton as true in ReportPreview.

if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL || policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
            return isAdmin && (isApproved || isManager);
}

We will update SettlementButton to hide Pay with expensify if policy.reimbursementChoice is reimburseManual or reimburseNo here

const shouldShowPaywithExpensifyOption = !shouldHidePaymentOptions && policy?.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL;

to

const shouldShowPaywithExpensifyOption = !shouldHidePaymentOptions 
&& policy?.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL;
&& policy?.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;

What alternative solutions did you explore? (Optional)

None

@truph01
Copy link
Contributor

truph01 commented Sep 28, 2024

Proposal updated

@ZhenjaHorbach
Copy link
Contributor

@truph01 @kushu7
Thanks for your proposals
I will check today or tomorrow !

Copy link

melvin-bot bot commented Sep 30, 2024

Current assignee @blimpich is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 30, 2024
Copy link

melvin-bot bot commented Sep 30, 2024

📣 @ZhenjaHorbach 🎉 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

Copy link

melvin-bot bot commented Sep 30, 2024

📣 @truph01 🎉 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 📖

@truph01
Copy link
Contributor

truph01 commented Oct 1, 2024

PR is ready

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 4, 2024
@melvin-bot melvin-bot bot changed the title [$250] [Instant Submit] Retain the option to Pay elsewhere on processing/submitted reports when payments get disabled. [HOLD for payment 2024-10-11] [$250] [Instant Submit] Retain the option to Pay elsewhere on processing/submitted reports when payments get disabled. Oct 4, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 4, 2024
Copy link

melvin-bot bot commented Oct 4, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Oct 4, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.44-12 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-10-11. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Oct 4, 2024

BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@ZhenjaHorbach] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
  • [@garrettmknight] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 11, 2024
@garrettmknight
Copy link
Contributor

garrettmknight commented Oct 11, 2024

Payment Summary:

@garrettmknight
Copy link
Contributor

@ZhenjaHorbach please propose the regression test and I'll pay out your contract.

@ZhenjaHorbach
Copy link
Contributor

BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

Regression Test Proposal

  • Create two new users, A and B
  • Have user A create a workspace and invite user B to the workspace as an employee
  • As user B, create an expense on the workspace
  • As user A, verify that you can see the expense that user B made but that there is no "Pay with Expensify" and/or "Pay elsewhere" button for the expense
  • As user A, go to Settings > Workspaces > your_workspace > More features and turn on "Workflows"
  • Go to Workflows tab and turn on "Make or track payments"
  • As user B submit an expense to your_workspace
  • As user A, verify that you can see the recently made expense and that it says "Pay with Expensify" and/or "Pay elsewhere"
  • As user A go to Workflows tab and turn off "Make or track payments"
  • As user A navigate to the newly submitted expense
  • Verify that there should be an option to "Pay Elsewhere" on the expense for user A

Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added the Overdue label Oct 14, 2024
@ZhenjaHorbach
Copy link
Contributor

Not overdue !

Copy link

melvin-bot bot commented Oct 14, 2024

@garrettmknight, @blimpich, @ZhenjaHorbach, @truph01 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@garrettmknight
Copy link
Contributor

Paid, closing!

@github-project-automation github-project-automation bot moved this from Release 2.5: SuiteWorld (Sept 9th) to Done in [#whatsnext] #wave-collect Oct 15, 2024
@melvin-bot melvin-bot bot removed the Overdue label Oct 15, 2024
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 Daily KSv2 External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item.
Projects
No open projects
Status: Done
Development

No branches or pull requests

8 participants