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.36k stars 2.78k forks source link

[$250] Wrong validation message when sending invoice #49286

Open m-natarajan opened 1 week ago

m-natarajan commented 1 week 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.35-7 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @dubielzyk-expensify Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1726459401827979

Action Performed:

  1. Click green (+) button
  2. Send invoice
  3. Enter $200
  4. Choose recipient
  5. Fill in company name (Dubby Co)
  6. Fill in company website (www.dubbyco.com)

    Expected Result:

    Expected www.dubbyco.com to be a valid website address

    Actual Result:

    Gives error saying "Please enter a valid website using lowercase characters"

    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/user-attachments/assets/0767a4d7-0299-4c3a-a5e9-ef6ad18e1e82

View all open jobs on GitHub

https://github.com/user-attachments/assets/4344065d-2b4c-4a91-9631-8b74a128f25a

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021835835067982464212
  • Upwork Job ID: 1835835067982464212
  • Last Price Increase: 2024-09-24
Issue OwnerCurrent Issue Owner: @ahmedGaber93
melvin-bot[bot] commented 1 week ago

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

nkdengineer commented 1 week ago

Edited by proposal-police: This proposal was edited at 2024-09-19 08:21:17 UTC.

Proposal

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

Wrong validation message when sending invoice

What is the root cause of that problem?

Here, we are considering that a valid website must include http/https/ftp in the URL, so a website like www.example.com would be an invalid website.

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

We should add the https:// prefix by using the Str.sanitizeURL function when validating the website and submitting the form here and here

      if (!ValidationUtils.isValidWebsite(Str.sanitizeURL(values.companyWebsite))) {
          errors.companyWebsite = translate('bankAccount.error.website');
      }

https://github.com/Expensify/App/blob/37bf6b2fef128786dfcd83257a56f56c0cd1eb3d/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx#L52

      IOU.sendInvoice(currentUserPersonalDetails.accountID, transaction, report, undefined, policy, policyTags, policyCategories, values.companyName, Str.sanitizeURL(values.companyWebsite));

https://github.com/Expensify/App/blob/37bf6b2fef128786dfcd83257a56f56c0cd1eb3d/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx#L72

OPTIONAL: We should also do the same in several places within the app that use the isValidWebsite function like here and here

What alternative solutions did you explore? (Optional)

github-actions[bot] commented 1 week ago

Jon Øvrebø Dubielzyk Your proposal will be dismissed because you did not follow the proposal template.

Krishna2323 commented 1 week ago

Edited by proposal-police: This proposal was edited at 2024-09-19 15:55:37 UTC.

Proposal


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

Wrong validation message for website when sending invoice.

What is the root cause of that problem?

We are using isValidWebsite for validation which requires http/https/ftp URL scheme.

https://github.com/Expensify/App/blob/6c8211166e3b570a8947f6ff07a35973ecbcffb8/src/libs/ValidationUtils.ts#L236-L243 https://github.com/Expensify/App/blob/12779f1f3cc940b94cd0fd6de53775265217e6cd/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx#L52

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


What alternative solutions did you explore? (Optional)

What alternative solutions did you explore? (Optional 2)

melvin-bot[bot] commented 1 week ago

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

melvin-bot[bot] commented 1 week ago

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

bikramiter commented 1 week ago

https://github.com/Expensify/App/blob/3c6526d79ddefc71b18c07139ce02f02d3543b8d/src/libs/ValidationUtils.ts#L236-L243

Note: As mentioned in the comment, this might need the corresponding scheme handling on the backend as well.

ahmedGaber93 commented 1 week ago

this might need the corresponding scheme handling on the backend as well.

I think it should be done in FE side, not BE. by adding the URL scheme if not found before sending to BE

ahmedGaber93 commented 1 week ago

Based on the issue Slack conversation, We have three possible options to fix this issue:

  1. allow user to type URL without https:// and add it in behalf of the user before sending to BE
  2. keep the current validation and just displaying the correct error message e.g. url must start with https://
  3. add a default value https:// prefix on the input like this

Screenshot 2024-09-17 at 11 20 10 PM

Just to confirm, the expected result is option one? @kadiealexander @dubielzyk-expensify

dubielzyk-expensify commented 1 week ago

My personal take is 1 and 3 should be done here, but I dunno the technical or security implications of 1. I'd at least say 3 should be done.

Keen to hear what @trjExpensify @JmillsExpensify @Expensify/design thinks

shawnborton commented 1 week ago

Yeah that makes sense to me. Or even just do 2 and 3 might be easy without needing back end changes?

dubielzyk-expensify commented 1 week ago

Yeah that also works. Feels a bit inelegant that we don't validate it properly though, but perhaps it's the right priority at this time 👍

ahmedGaber93 commented 1 week ago

I think We can use option one without any backend change, we will allow the user to type www.dubbyco.com and send the complete format https://www.dubbyco.com to the backend.

We already have a function for adding the missing https:// protocol in frontend sanitizeURL

shawnborton commented 1 week ago

Oh nice, that's great then!

nkdengineer commented 1 week ago

updated proposal following this comment here

Krishna2323 commented 1 week ago

@ahmedGaber93, I believe we used prefix in the app somewhere in the past, maybe on the business details page, and adding it also helps the user understand that only https:// is accepted. It provides a visual reminder that only https:// is allowed, offering instant feedback while maintaining control over the protocol.

WDYT @shawnborton @dubielzyk-expensify?

dubielzyk-expensify commented 1 week ago

Sure. Let's go with option 1 and 3 then unless @shawnborton thinks otherwise. If it's all front-end stuff then chuck the prefix in and validate it to be a URL 👍

ahmedGaber93 commented 1 week ago

@dubielzyk-expensify the option 3 is already used on company website on bank account steps, but it has two cases

A. if user email is not on private domain, the default value will be prefix https://
B. if user email is on private domain, the default value will be generated website url https://www.privatedomain.com

Should we use the same UX behavior here for consistency or just use case A? And if we will use the both cases, should we also add default value for company name like case B (if user email is on private domain, company name default value will be privatedomain)?

shawnborton commented 1 week ago

I'm down with a combo of 1 and 3. As for the latest question... I feel like the default value of https:// would be enough?

ahmedGaber93 commented 1 week ago

Thanks, that's great.

trjExpensify commented 1 week ago

I'm not sure I'm following the 1 and 3 combo really. If we do 3, https:// is prefixed in the field and can't be removed, so wouldn't doing 3 only be enough?

If @ahmedGaber93 is saying in the bank account flow we populate your private domain email address into the field already, that kinda' makes sense to copy/paste over here in the invoice flow.

Krishna2323 commented 1 week ago

Proposal Updated

ahmedGaber93 commented 1 week ago

If we do 3, https:// is prefixed in the field and can't be removed, so wouldn't doing 3 only be enough?

@trjExpensify https:// can be removed by the user. It's a default value for the input. and this is the way we used in bank account flow

Krishna2323 commented 1 week ago

@ahmedGaber93 https:// can't be removed if we use prefixCharacter prop.

trjExpensify commented 1 week ago

@trjExpensify https:// can be removed by the user. It's a default value for the input. and this is the way we used in bank account flow

Oh right, that seems silly doesn't it if we require it?

ahmedGaber93 commented 1 week ago

Yeah, I am not sure if it required or not. But maybe we need to allow the user to remove it and type other scheme like http://

ahmedGaber93 commented 1 week ago

@Krishna2323 Yes, prefixCharacter="https://" also can be another possible option

dubielzyk-expensify commented 1 week ago

I'm okay with only doing 3 👍

shawnborton commented 1 week ago

Works for me too!

ahmedGaber93 commented 1 week ago

Ok, but the https:// prefix will be removable or not? It is removable in current bank account flow

dubielzyk-expensify commented 6 days ago

I think we should still technically make it removable if we also allow http://. Will also make it easier to copy a link if users prefer to do that.

ahmedGaber93 commented 6 days ago

Ok, I will summarize the expected behavior from discussion to be clear for contributors

  1. Add a removable https:// prefix link
  2. If user email is on a private domain, populate a default value from this domain link paragraph 2

This behavior is exactly like the bank account flow.

joekaufmanexpensify commented 5 days ago

Noting I came across this same issue and reported it here. But we're not proceeding as I see we're fixing it here!

ahmedGaber93 commented 5 days ago

@Krishna2323 Your proposal looks to have what we need to move forward, but can you update your proposal to clean the unnecessary points and make it match this expected behavior https://github.com/Expensify/App/issues/49286#issuecomment-2367859204

Screenshot 2024-09-23 at 9 30 51 PM

Krishna2323 commented 5 days ago

@ahmedGaber93, main solution updated.

melvin-bot[bot] commented 5 days ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

ahmedGaber93 commented 4 days ago

@Krishna2323 's proposal LGTM!

🎀 👀 🎀 C+ reviewed.

melvin-bot[bot] commented 4 days ago

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

marcaaron commented 3 days ago

allow user to type URL without https:// and add it in behalf of the user before sending to BE

How would we know that the website uses https?

I'm not really following why we require https:// at all? It doesn't seem like it would be necessary.

ahmedGaber93 commented 3 days ago

allow user to type URL without https:// and add it in behalf of the user before sending to BE How would we know that the website uses https?

@marcaaron This was one of the possible options, but we didn't decide to use it. We have chosen the option 3 "add a default value https:// prefix on the input like this"

Screenshot 2024-09-17 at 11 20 10 PM

This default value https:// is removable, so user able to remove it and type http://. We already have the same behavior on bank account flow.