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

[PAID] [$500] Web - Composer send button is enabled even when the input contains only space #26433

Closed
1 of 6 tasks
kbecciv opened this issue Aug 31, 2023 · 40 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Aug 31, 2023

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


Action Performed:

  1. Open any chat
  2. Type multiple spaces and verify the send button is still disabled
  3. Close the chat or navigate to another chat
  4. Open back the chat

Expected Result:

The send button stays disabled because it contains only space

Actual Result:

The send button is enabled

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.60.1
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
Notes/Photos/Videos: Any additional supporting documentation

Screen.Recording.2023-08-26.at.16.06.42.mov
Recording.4142.mp4

Expensify/Expensify Issue URL:
Issue reported by: @bernhardoj
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693037242762969

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0148ad3caa7badc613
  • Upwork Job ID: 1697749457182527488
  • Last Price Increase: 2023-09-01
  • Automatic offers:
    • fedirjh | Reviewer | 26518770
    • bernhardoj | Contributor | 26518772
    • bernhardoj | Reporter | 26518773
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 31, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 31, 2023

Triggered auto assignment to @strepanier03 (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Aug 31, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@kbecciv
Copy link
Author

kbecciv commented Aug 31, 2023

Proposal by: @bernhardoj
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693037242762969

Proposal

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

The composer send button is enabled even when it contains only space.

What is the root cause of that problem?

We disable the send button if isCommentEmpty state is true. The initial value of isCommentEmpty comes from isCommentEmptyProp.

const [isCommentEmpty, setIsCommentEmpty] = useState(isCommentEmptyProp);

https://github.com/Expensify/App/blob/c16995257c738761206ea07645e863ee717ecbc0/src/pages/home/report/ReportActionCompose/ReportActionCompose.js#[…]8
Notice that we check using _.isEmpty which considers space only as not empty. This is different from what we do when typing something in the composer.
https://github.com/Expensify/App/blob/c16995257c738761206ea07645e863ee717ecbc0/src[…]ages/home/report/ReportActionCompose/ComposerWithSuggestions.js

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

This issue happens after the ReportActionCompose refactor. Previously, when the composer mounted, we always called updateComment to make sure isCommentEmpty had a correct value, but this approach raised this issue.
Even though the issue is marked as not a bug, I still think it's a bug and we shouldn't use the old approach which is a workaround. To fully solve the issue, we should replace _.isEmpty with the regex we use when typing in the composer.

isCommentEmpty: {
    selector: (comment) => !comment || !!comment.match(/^(\s)*$/)
// comment could be undefined, so we also use !comment

@alifhaider
Copy link

Proposal

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

Composer send button is not disabled when typed text is only spaces

What is the root cause of that problem?

Send Button is only checking for disabled if field is empty or not.

isCommentEmpty: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`,
selector: (comment) => _.isEmpty(comment),
},

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

We can trim the comment and then update isCommentEmpty. By this, it will remove the start and ending spaces of text, and then make the button enabled and disabled based on that.

isCommentEmpty: {
            key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`,
            selector: (comment) => _.isEmpty(comment) || _.isEmpty(comment.trim()),
        },

What alternative solutions did you explore? (Optional)

N/A

@melvin-bot
Copy link

melvin-bot bot commented Aug 31, 2023

📣 @alifhaider! 📣
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. 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.
  2. 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.
  3. 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>

@alifhaider
Copy link

Contributor details
Your Expensify account email: alifhaider57@gmail.com
Upwork Profile Link: (https://www.upwork.com/freelancers/~014066482556c551be)

@melvin-bot
Copy link

melvin-bot bot commented Aug 31, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@alphaboss1104
Copy link
Contributor

Proposal

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

Composer send button is not disabled when typed text is only spaces

What is the root cause of that problem?

We disable the send button if isCommentEmpty state is true.
We set the isCommentEmpty 's value by comment is empty or not when the chat is reopened or navigated back to.

isCommentEmpty: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`,
selector: (comment) => _.isEmpty(comment),
},

This is the root cause of this issue.

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

We should also check if the comment is a string full of spaces like this.

        isCommentEmpty: {
            key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`,
            selector: (comment) => _.isEmpty(comment) || !!comment.match(/^(\s)*$/),
        },

What alternative solutions did you explore? (Optional)

We can also be resolved by adding a check in the useEffect hook that handles the reopening or navigation back to chat here.

    useEffect(() => {
        if (value.length === 0) {
            return;
        }

+       setIsCommentEmpty(value.trim().length === 0);

        Report.setReportWithDraft(reportID, true);
    }, []);

@strepanier03 strepanier03 added the External Added to denote the issue can be worked on by a contributor label Sep 1, 2023
@melvin-bot melvin-bot bot changed the title Web - Composer send button is enabled even when the input contains only space [$500] Web - Composer send button is enabled even when the input contains only space Sep 1, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 1, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 2023

Current assignee @strepanier03 is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 2023

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

@muradkhan101
Copy link

Proposal

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

The Composer send button is disabled correctly when entering spaces inside of a chat but it is incorrectly enabled when re-entering that same chat room

What is the root cause of that problem?

When loading the page initially, the send button's disabled state is set by the initial value of isCommentEmptyProp, which is set here using _.isEmpty.

selector: (comment) => _.isEmpty(comment),

However, when the state is updating while chatting, the value is set by using regex.

setIsCommentEmpty(!!newComment.match(/^(\s)*$/));

The issue is that there is no common helper function to check whether a comment is empty so two different implementations currently exist.

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

I think we should create a common isTextInputEmpty helper method that will use the regex to determine if the comment is empty. Then we update all code locations to use this helper instead of having their own implementation.

What alternative solutions did you explore? (Optional)

Just update all locations to use the regex but this issue can happen again later if a new engineer doesn't know to use the regex. The common helper method should resolve that issue

@rsiota
Copy link

rsiota commented Sep 2, 2023

Proposal

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

When we open a chat and type multiple spaces in the composer, the send button remains disabled. But if we switch chats and navigate back to the original chat, the send button becomes enabled, instead of remaining disabled.

What is the root cause of that problem?

The root cause of the problem is that the check used to determine if a comment is empty, uses the _.isEmpty() underscore function, which, for strings and array-like objects, checks if the length property is 0. This function doesn't account for white spaces within a string.

The current check happens on ReportActionCompose.js, in the following lines:

452    isCommentEmpty: {
453        key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`,
454        selector: (comment) => _.isEmpty(comment),
455    },

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

I would propose to add a further check to determine if the empty comment has white spaces. I think that it would be useful to have a utility function that could be composed when doing the check.

I was looking for a place on the basecode that might be appropriate for adding the utitlity function, and I thought of ReportUtil.js, but, without knowing the basecode in depth, I understand, there might be other files, where this utility function, might be more appropriately placed.

I would suggest the following changes:

ReportUtil.js

/**
* Checks if a comment has white space
*
* @param {String} comment
* @returns {Boolean}
*/
function hasWhiteSpace(comment) {
    return /\s/g.test(comment);
} 
export {
    ...
    hasWhiteSpace,
    ...
};

ReportActionCompose.js

isCommentEmpty: {
    key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`,
    selector: (comment) => _.isEmpty(comment) || ReportUtils.hasWhiteSpace(comment),
},

What alternative solutions did you explore? (Optional)

An alternative solution would be to inline the check for white spacing directly, instead of using a separate function. I thought that using a separate function might help with readability.

@melvin-bot
Copy link

melvin-bot bot commented Sep 2, 2023

📣 @rsiota! 📣
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. 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.
  2. 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.
  3. 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>

@rsiota
Copy link

rsiota commented Sep 2, 2023

Contributor details
Your Expensify account email: rsiota@gmail.com
Upwork Profile Link: (https://www.upwork.com/en-gb/freelancers/~016641e7b5affe3105)

@melvin-bot
Copy link

melvin-bot bot commented Sep 2, 2023

⚠️ Missing/invalid email or upwork profile link. Please make sure you add both your Expensify email and Upwork profile link in the format specified.

@melvin-bot melvin-bot bot added the Overdue label Sep 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 4, 2023

@strepanier03, @fedirjh Whoops! This issue is 2 days overdue. Let's get this updated quick!

@fedirjh
Copy link
Contributor

fedirjh commented Sep 5, 2023

Thanks everyone for the proposal.

Looks like @bernhardoj's solution has a straightforward fix for this issue. Let's proceed with it.

🎀 👀 🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Sep 5, 2023

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

@aldo-expensify
Copy link
Contributor

I'm not being able to assign @bernhardoj for the moment

image

I was having some problems with Github crashing a few minutes ago, maybe is related to that, I'll try later.

@melvin-bot
Copy link

melvin-bot bot commented Sep 6, 2023

📣 @bernhardoj 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 6, 2023
@bernhardoj
Copy link
Contributor

PR is ready

cc: @fedirjh

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @bernhardoj got assigned: 2023-09-06 03:31:26 Z
  • when the PR got merged: 2023-09-25 04:02:40 UTC
  • days elapsed: 13

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 28, 2023
@melvin-bot melvin-bot bot changed the title [$500] Web - Composer send button is enabled even when the input contains only space [HOLD for payment 2023-10-05] [$500] Web - Composer send button is enabled even when the input contains only space Sep 28, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Sep 28, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 28, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 28, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.74-3 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 2023-10-05. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter - @bernhardoj - $50 via Upwork
  • Contributor that fixed the issue - @bernhardoj - $500 - $250 = $750 via Upwork
  • Contributor+ that helped on the issue and/or PR - @fedirjh - $500 - $250 = $750 via Upwork

Bonus assessment discussion: I took a look at the PR and it looks like this was ready for our review on September 6 and other factors delayed the merge.

  • C+ approved on 9/6
  • We placed the PR on hold with reason "Merge Freeze" on 9/6
  • The C+ bumped the engineer that it was ready to be merged on 9/12
  • We held until the next deploy due to the number of PRs on 9/12
  • The C+ bumped the engineer to merge on 9/22
  • The PR was merged on 9/22

In light of this, I am going to pay the urgency bonus.

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

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Sep 28, 2023

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 5, 2023
@strepanier03
Copy link
Contributor

@bernhardoj - You've been paid in Upwork. I left a note on the bonus payment but I thought we had two separate contracts for this job for you so I added the bonus to pay the reporting payment after the fact. Let me know if you have any questions.

@fedirjh - I'll keep my eyes open for an update on the checklist and move forward once there's one.

Thanks everyone!

@bernhardoj
Copy link
Contributor

@strepanier03 got it. Thanks! I think you can close the Reporter contract then.

@fedirjh
Copy link
Contributor

fedirjh commented Oct 6, 2023

BugZero Checklist:


Regression Test Proposal

  1. Open any chat
  2. Type space into the composer.
  3. Verify the send button is disabled.
  4. Switch to another chat
  5. Open the chat back
  6. Verify the send button is still disabled.
  • Do we agree 👍 or 👎

@fedirjh
Copy link
Contributor

fedirjh commented Oct 6, 2023

@strepanier03 The offer was expired for me, could you please send me another offer 🙏🏼

@strepanier03
Copy link
Contributor

Sure thing @fedirjh, I'll do that now.

@strepanier03
Copy link
Contributor

@fedirjh - Sent!

Working on reg test GH now.

@strepanier03
Copy link
Contributor

@bernhardoj - I'll work on closing that next week. For some reason both contracts linked here are for the same contract and paid already.

@melvin-bot melvin-bot bot added the Overdue label Oct 9, 2023
@fedirjh
Copy link
Contributor

fedirjh commented Oct 9, 2023

@strepanier03 Accepted, Thank you.

@melvin-bot melvin-bot bot removed the Overdue label Oct 9, 2023
@strepanier03
Copy link
Contributor

@fedirjh - I have finished paying you as well. Thanks for accepting that.

Thank you both for being part of our community and working so hard to help us achieve the New Expensify dream.

@strepanier03 strepanier03 changed the title [HOLD for payment 2023-10-05] [$500] Web - Composer send button is enabled even when the input contains only space [PAID] [$500] Web - Composer send button is enabled even when the input contains only space Oct 9, 2023
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 Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

9 participants