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.51k stars 2.86k forks source link

[$250] Approvers Flow - Admin gets error when paying expense to employee without bank account #48545

Closed IuliiaHerets closed 1 month ago

IuliiaHerets commented 1 month ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.29-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/4922007 Email or phone of affected tester (no customers): fischer9966+090324badm@gmail.com Issue reported by: Applause Internal Team

Action Performed:

Precondition NewDot:

  1. Create admin account with Gmail
  2. Create Collect workspace, set Workflows to enabled
  3. Invite Employee with Gmail accounts to this workspace
  4. Enable Approvals in Workflows and set Admin as Approver
  5. Enable Workflows > Delay submissions and set it to Manually
  6. Login as the employee and submit a report
  7. Login as the admin and approve this report

Precondition OldDot:

  1. Login to OD as Admin
  2. Go to Collect workspace > Reimbursements
  3. Select "Direct" and connect Bank account

Steps NewDot:

  1. Go to staging.new.expensify.com or open App
  2. Login as the admin and pay report from precondition steps with bank account

Expected Result:

Admin gets a message "Payment is on hold until Employee One adds a bank account." Report in approved state. No payment button.

Actual Result:

Admin gets an error message "An unexpected error occurred. Please try again." Expense remains unpaid. "Pay with bank account" button is present.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/54fb3f6b-f0c3-42e1-b871-b20477a2b443

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021831395256513073087
  • Upwork Job ID: 1831395256513073087
  • Last Price Increase: 2024-09-04
Issue OwnerCurrent Issue Owner: @akinwale
melvin-bot[bot] commented 1 month ago

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

IuliiaHerets commented 1 month ago

@sakluger 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

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 1 month ago

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

trjExpensify commented 1 month ago

@IuliiaHerets it would be super helpful to open the JS console > network, then press the button to hit the error, and check the response of the failed API command.

trjExpensify commented 1 month ago

Internal logs

Throw ExpException - d1cbd3c64a46b9acc503d06b59a1e863 ~~ message: '403 Invalid payment type' exceptionMessage: 'Auth PayMoneyRequest returned an error' exceptionFile: '/git/releases/expensify.com/544aee4/lib/Auth.php' exceptionLine: '128' exceptionCode: '403'
API threw ExpError Expensify\Libs\Error\ExpError - 85427d9f-f33a-47af-ae93-2249272d9fa6 ~~ onyxData: '[0: '[onyxMethod: 'merge' key: 'reportActions_1878202399790691' value: '[8653849744632496594: '[errors: '[1725421051483334: 'An unexpected error occurred. Please try again.']']']']']' exceptionJsonCode: '666' exceptionUserMessage: 'An unexpected error occurred. Please try again.' exceptionMessage: 'An unexpected error occurred. Please try again.' exceptionFile: '/git/releases/expensify.com/544aee4/lib/ReportAPI.php' exceptionLine: '5085' exceptionCode: '666'

That's throwing in Auth here: https://github.com/Expensify/Auth/blob/47faeb84d60f0f9b7a56f99dc5f4e8e533c7ee54/auth/command/PayMoneyRequest.cpp#L138-L142

    paymentType = request["paymentType"];
    const set<string> allowedPaymentTypes = {Report::PAYMENT_TYPE_ELSEWHERE, Report::PAYMENT_TYPE_ACH};
    if (!SContains(allowedPaymentTypes, paymentType)) {
        STHROW("403 Invalid payment type");
    }

I suspect this is another bug coming from changes made in this issue and this PR.

We can see here in the payMoneyRequest request that the paymentMethodType is businessBankAccount and that's not valid, so we're hitting the error paying expense reports.

Processing 'PayMoneyRequest' for 'expensify.com' from '50.88.198.46' ~~ browserGUID: '66d7c963cdbeb' initialReferer: '<REDACTED>' command: 'PayMoneyRequest' iouReportID: '1878202399790691' chatReportID: '7261543974099434' reportActionID: '8653849744632496594' paymentMethodType: 'businessBankAccount' full: 'true' amount: '11000' pusherSocketID: '766448.11880468' authToken: '<REDACTED>' referer: 'ecash' platform: 'ios' api_setCookie: 'false' email: 'fischer9966+090324badm@gmail.com' isFromDevEnv: 'false' appversion: '9.0.29-0' clientUpdateID: '1599539467' partnerName: 'expensify.com' HTTP_CF_BOT_SCORE: '99' HTTP_CF_JA3_HASH: 'b76d503360ae441d410a85a7f8d648ab'
trjExpensify commented 1 month ago

Going to fix this with a revert here: https://github.com/Expensify/App/pull/48639#issuecomment-2331681141

mountiny commented 1 month ago

Do we need to keep this opened? Or assigned someone who is leading charge on the refactor?

trjExpensify commented 1 month ago

Nah, we can use the parent issue for the PR that tried to introduce these changes.