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.54k stars 2.89k forks source link

[HOLD for Payment 2024-09-6] [$250] Tags - mWeb - Creating expense with tag G : : displays tag no longer valid error #46494

Closed lanitochka17 closed 3 days ago

lanitochka17 commented 3 months 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.14 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/4784898 Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Tap profile icon - workspaces-- workspace
  3. Tap more features - enable tags
  4. Tap on tags - add a tag
  5. Enter G : : and save the tag
  6. Navigate to workspace chat
  7. Tap plus icon near compose and select submit expense
  8. Enter an amount and tap next
  9. Enter merchant and tap more
  10. Select tag
  11. Submit expense
  12. Open the created expense and note tag field

Expected Result:

Creating expense with tag G : : must not display tag no longer valid error

Actual Result:

Creating expense with tag G : : displays tag no longer valid error

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/6b8a0c7d-a311-4135-8c34-aa3b548a0488

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c81e89645f07ad39
  • Upwork Job ID: 1818483515236941638
  • Last Price Increase: 2024-07-31
  • Automatic offers:
    • situchan | Reviewer | 103430485
Issue OwnerCurrent Issue Owner: @daledah
melvin-bot[bot] commented 3 months 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.

lanitochka17 commented 3 months 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

FitseTLT commented 3 months ago

Proposal

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

Tags - mWeb - Creating expense with tag G : : displays tag no longer valid error

What is the root cause of that problem?

This is because we are removing the last colons here https://github.com/Expensify/App/blob/3722b22302e5d89f2916d5e8958b2cf17ecb6285/src/libs/IOUUtils.ts#L144-L145 which will create an incompatibility with the tag of the workspace which is G ::

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

We are removing the last colons to remove empty multilevel tags which are joined by a colon here https://github.com/Expensify/App/blob/3722b22302e5d89f2916d5e8958b2cf17ecb6285/src/libs/IOUUtils.ts#L144-L145 But we need to make sure that the colons are not preceded by a backslash \ because that would mean the colon is part of the tag name as the backend normally returns colons after escaping with backslashes. So we need to change it to

    return tagArray.join(CONST.COLON).replace(/(?<!\\):*$/, '');

What alternative solutions did you explore? (Optional)

sakluger commented 3 months ago

Making this external. Let's be careful to keep in mind that colons are how we store different levels of tags with multi-level tags.

melvin-bot[bot] commented 3 months ago

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

melvin-bot[bot] commented 3 months ago

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

daledah commented 3 months ago

Proposal

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

Creating expense with tag G : : displays tag no longer valid error

What is the root cause of that problem?

In https://github.com/Expensify/App/blob/881c5482facc08af709f047025c863ad67b6d5b3/src/libs/IOUUtils.ts#L144, we always remove the last :, the aim was to remove empty multi-level tags. However in this case the : is user input and is formatted as \: by the back-end, but we're wrongly removing the last :.

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

We should filter the empty item at the last of tagArray instead of using Regex here

while (tagArray.length > 0 && !tagArray[tagArray.length - 1]) {
    tagArray.pop();
}

return tagArray.join(CONST.COLON);

This will preserve existing last : removal behavior, but if empty tags should be removed if it's in the middle too, above can be simplified by just using filter to filter out empty item in tagArray. We could also trim the tagArray item before checking its emptyness.

What alternative solutions did you explore? (Optional)

I tried updating the Regex to use look behind like above proposal but it doesn't work for multiple browsers (like older Safari version), reference: https://caniuse.com/js-regexp-lookbehind. Also IMO we should try to avoid using Regex as much as possible because it's hard to read.

situchan commented 3 months ago

2 proposals in review

melvin-bot[bot] commented 3 months ago

πŸ“£ @webdog12345! πŸ“£ Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
webdog12345 commented 3 months ago

Expensify Tag is changed to G: it happens because of this function.(App/src/libs/IOUUtils.ts Line140) function insertTagIntoTransactionTagsString(transactionTags: string, tag: string, tagIndex: number): string { const tagArray = TransactionUtils.getTagArrayFromName(transactionTags); tagArray[tagIndex] = tag;

   return tagArray.join(CONST.COLON).replace(/:*$/, '');

}

we can change this function like this function insertTagIntoTransactionTagsString(transactionTags: string, tag: string, tagIndex: number): string { const tagArray = TransactionUtils.getTagArrayFromName(transactionTags); // Update the tag at the specified index tagArray[tagIndex] = tag;

   // Use CONST.COLON to join tags and ensure double colons are preserved
   return tagArray.join(CONST.COLON.repeat(2)).replace(new RegExp(`${CONST.COLON}{2,}$`), '');

} I have read and understood contributing guidelines. Your Expensify account email: AnsonHelbert0127@gmail.com Upwork Profile Link: https://www.upwork.com/freelancers/arturl39

melvin-bot[bot] commented 3 months ago

@sakluger, @situchan Eep! 4 days overdue now. Issues have feelings too...

sakluger commented 3 months ago

Hey @situchan - it looks like we have a few proposals ready for review.

situchan commented 3 months ago

image

Agree we should avoid negative lookbehind.


using filter to filter out empty item in tagArray. We could also trim the tagArray item before checking its emptyness.

@daledah's proposal looks good. πŸŽ€πŸ‘€πŸŽ€ C+ reviewed

melvin-bot[bot] commented 3 months ago

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

Julesssss commented 3 months ago

but if empty tags should be removed if it's in the middle too, above can be simplified by just using filter to filter out empty item in tagArray. We could also trim the tagArray item before checking its emptyness.

πŸ‘

melvin-bot[bot] commented 3 months ago

πŸ“£ @situchan πŸŽ‰ 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

melvin-bot[bot] commented 3 months ago

πŸ“£ @daledah You have been assigned to this job! Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs! Keep in mind: Code of Conduct | Contributing πŸ“–

daledah commented 3 months ago

@situchan this PR is ready for review.

paultsimura commented 2 months ago

@daledah @situchan seems like this caused https://github.com/Expensify/App/issues/47631, could you please check while it is still within the regression period?

daledah commented 2 months ago

@paultsimura I'm working on a PR right now.

melvin-bot[bot] commented 2 months ago

This issue has not been updated in over 15 days. @sakluger, @Julesssss, @situchan, @daledah eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

situchan commented 2 months ago

⚠️ We just got confirmation on Slack that the Deploy Checklist: New Expensify 2024-08-26 which includes the PR of this issue was only deployed to production today in Deploy Checklist: New Expensify 2024-08-28. More context on why this happened can be found in this Slack thread and this Slack comment.

Given the context above, this issue should be on [HOLD for Payment 2024-09-6] according to today's production deploy from Deploy Checklist: New Expensify 2024-08-28.

situchan commented 1 month ago

We already have regression test - https://expensify.testrail.io/index.php?/tests/view/4784898

Julesssss commented 1 month ago

Ready for payment @sakluger πŸ‘

sakluger commented 2 weeks ago

Sorry for the delay - I missed this since it still had the monthly priority label. I'll process payment now.

sakluger commented 2 weeks ago

Summarizing payment on this issue:

Contributor: @daledah $250, please accept the Upwork offer: https://www.upwork.com/nx/wm/offer/104520924 Contributor+: @situchan $250, paid via Upwork

sakluger commented 2 weeks ago

Offer is still pending. We can close as soon as it's accepted and paid.

sakluger commented 2 weeks ago

I haven't seen @daledah in Slack or GH for the past few days, so they may be on leave. I'm going to set this to weekly and check back in a week.

daledah commented 1 week ago

Many thanks @sakluger I have accepted the offer

sakluger commented 3 days ago

Thanks @daledah, I've paid out the contract.