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.56k stars 2.9k forks source link

Invoices - Unable to send invoice if the company info is entered in Invoices settings first #51872

Open lanitochka17 opened 2 weeks ago

lanitochka17 commented 2 weeks 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.56-3 Reproducible in staging?: Y Reproducible in production?: N If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Email or phone of affected tester (no customers): applausetester+kh2410006@applause.expensifail.com Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Create a new workspace
  3. Go to workspace settings > More features
  4. Enable Invoices
  5. Go to Invoices
  6. Add the following information: Company name - Expensify Company address - https://staging.new.expensify.com/
  7. Go to FAB > Send invoice
  8. Send an invoice from the workspace created in Step 2
  9. Note that error is shown and the invoice cannot be sent
  10. Create another workspace
  11. Go to workspace settings and enable Invoices in More features
  12. Go to FAB > Send invoice
  13. Send an invoice from the new workspace created in Step 10, then add the same company info in Step 6 after the confirmation page

Expected Result:

User should be able to send invoice when the company name and address are saved in Invoices settings (Step 1 to 9)

Actual Result:

Error shows up and invoice is not sent when the company name and address are saved in Invoices settings. (Step 1 to 9) When the same company info is entered when sending info (Step 13), the invoice is sent successfully

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/6e47decf-75e4-44f3-8856-4138684873d1

View all open jobs on GitHub

github-actions[bot] commented 2 weeks ago

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.
melvin-bot[bot] commented 2 weeks ago

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

melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to @danieldoglas (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

melvin-bot[bot] commented 2 weeks ago

💬 A slack conversation has been started in #expensify-open-source

Nodebrute commented 2 weeks ago

Proposal

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

Unable to send invoice if the company info is entered in Invoices settings first

What is the root cause of that problem?

When we set the company information in the invoice settings first and then proceed to send the invoice, the invoice flow does not prompt for the company information again because it has already been set. However, in the parameters sent when invoicing, companyName and companyWebsite will be undefined, leading to a backend error indicating that the company information is missing. https://github.com/Expensify/App/blob/bfce2771d22cbecceee6cf3c064fe3f0627eb5d8/src/libs/actions/IOU.ts#L3744-L3745

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

In the 'send invoice' process, we can also include policy?.invoice?.companyName as a fallback in case the user has already set the company name in the policy. We should do the same for the company website here.

pseudo code

        companyName: policy?.invoice?.companyName ?? companyName,
        companyWebsite: policy?.invoice?.companyWebsite ?? companyWebsite,

Note: We can also reverse this logic to prioritize the companyName and companyWebsite passed in, falling back to the values from the policy only if they are not provided.

What alternative solutions did you explore? (Optional)

ShridharGoel commented 2 weeks ago

Edited by proposal-police: This proposal was edited at 2024-11-01 17:22:17 UTC.

Proposal

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

Invoices - Unable to send invoice if the company info is entered in Invoices settings first

What is the root cause of that problem?

The company name and website are not being passed to sendInvoice method below.

https://github.com/Expensify/App/blob/f7a29d3cd48b57de5cf9032f596f2c3d04781d20/src/pages/iou/request/step/IOURequestStepConfirmation.tsx#L459

This flow is used when the company details already exist in the policy.

When company details are not available, the flow goes to IOURequestStepCompanyInfo where the user needs to input these details.

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

Update it to the below:

if (iouType === CONST.IOU.TYPE.INVOICE) {
    IOU.sendInvoice(currentUserPersonalDetails.accountID, transaction, report, receiptFile, policy, policyTags, policyCategories, policy?.invoice?.companyName, policy?.invoice?.companyWebsite);
    return;
}
Julesssss commented 2 weeks ago

Downgrading this. It's a brand new feature.

@madmax330 @danieldoglas, if you disagree, let me know. I unsubscribed so please tag me.

rezkiy37 commented 1 week ago

Hi, I am Michael (Mykhailo) from Callstack, an expert agency and I can work on this issue. Moreover, I am the author of https://github.com/Expensify/App/pull/50571 and consider this as a regression issue.

rezkiy37 commented 1 week ago

That looks like a backend bug as well because happens only with newly created workspaces but not with legacy ones. It relates to https://github.com/Expensify/App/issues/51871 since the backend does not set the company name and website values. Also, the failure data is not used due to the server response.

Details

Screenshot 2024-11-05 at 13 06 03 Screenshot 2024-11-05 at 13 06 23

cc @madmax330

melvin-bot[bot] commented 1 week ago

@madmax330, @MitchExpensify Still overdue 6 days?! Let's take care of this!

madmax330 commented 1 week ago

Pr is up