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

[HOLD for payment 2024-01-24] [$500] Workspace - Invite message does not remain when refresh page #32835

Closed
3 of 6 tasks
kbecciv opened this issue Dec 11, 2023 · 27 comments
Closed
3 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 Dec 11, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.11-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
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Open staging.new.expensify.com
  2. Navigate to Settings> Workspace> Members> Invite
  3. Select few members to invite and click Next
  4. Add random invite message and confirm Invite button
  5. Refresh the page
  6. Repeat steps 2 & 3

Expected Result:

Once entered invite message should remain when invite more users when refresh the page

Actual Result:

Invite message does not remain when refresh page

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6309308_1702313690749.Recording__1529.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e780374dd3bf487d
  • Upwork Job ID: 1734260347582304256
  • Last Price Increase: 2023-12-18
  • Automatic offers:
    • DylanDylann | Contributor | 28064891
Issue OwnerCurrent Issue Owner: @bfitzexpensify
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 11, 2023
@melvin-bot melvin-bot bot changed the title Workspace - Invite message does not remain when refresh page [$500] Workspace - Invite message does not remain when refresh page Dec 11, 2023
Copy link

melvin-bot bot commented Dec 11, 2023

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

Copy link

melvin-bot bot commented Dec 11, 2023

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

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

melvin-bot bot commented Dec 11, 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

Copy link

melvin-bot bot commented Dec 11, 2023

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

@bernhardoj
Copy link
Contributor

Proposal

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

Refreshing the web app and revisiting the workspace invite message page won't show the previously saved invite message.

What is the root cause of that problem?

In workspace invite message page, we get the message from the onyx and use a selector.

workspaceInviteMessageDraft: {
key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`,
selector: (draft) => (isEmpty(draft) ? '' : draft),
},

Then, in the component constructor, we set the message state to the message from onyx if found.

this.state = {
welcomeNote: this.props.workspaceInviteMessageDraft || this.getDefaultWelcomeNote(),
};

But after we refresh the page, somehow the selector of onyx returns undefined value and will return the correct value for the 2nd render or after reopening the page. That's why the message from Onyx is empty and we get the default message.

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

I haven't dug deeper into the onyx code as to why selector gives an undefined value after refresh, but removing the selector will fix the issue. We previously used the selector when the message is in the form of an object.
image

But now the selector is useless.

@AmjedNazzal
Copy link
Contributor

Proposal

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

Workspace - Invite message does not remain when refresh page

What is the root cause of that problem?

The issue here is a simple case of react lifecycle no aligning with the intended behaviour, the welcomeNote is a state variable with a default value of either this.props.workspaceInviteMessageDraft or this.getDefaultWelcomeNote(), But workspaceInviteMessageDraft is populated from an asynchronous data fetch, therefore on the component mounting it will be empty and the code will default to the default welcome message.

this.state = {
welcomeNote: this.props.workspaceInviteMessageDraft || this.getDefaultWelcomeNote(),
};

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

We already have a componentDidUpdate being used to ensure state variables are populated correctly so we just have to add a simple check in there to ensure that the welcomeNote is included

componentDidUpdate(prevProps) {
    ...
    if(prevProps.workspaceInviteMessageDraft !== this.props.workspaceInviteMessageDraft){
        this.setState({welcomeNote: this.props.workspaceInviteMessageDraft});
    }

Result

Screen.Recording.2023-12-11.at.11.45.38.PM.mov

@DylanDylann
Copy link
Contributor

DylanDylann commented Dec 12, 2023

Proposal

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

  • Workspace - Invite message does not remain when refresh page

What is the root cause of that problem?

withOnyx() will delay the rendering of the wrapped component until all keys/entities have been fetched and passed to the component

  • And, we know that whether all the keys/entities have been fetched or not based on the value, if any key have value is undefined, so its data is not fetched, if any key have value is nulll, so its data is fetched successfully and have null value.
  • In this bug, we have the selector:
    workspaceInviteMessageDraft: {
    key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`,
    selector: (draft) => (isEmpty(draft) ? '' : draft),
    },

    that always returns a value that is not undefined value. And as I mentioned above, it will consider that all the keys have been fetched successfully but the fact is that the workspaceInviteMessageDraft `s data is not fetched, and goes to render the wrapped component, in this case, is WorkspaceInviteMessage page.
  • Then, it will set the message invite with the default message:
    welcomeNote: this.props.workspaceInviteMessageDraft || this.getDefaultWelcomeNote(),

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

  • Based on the above RCA, we need to make sure that all keys/entities are fetched before render the page. We can just update the selector to:
 selector: (draft) => {
                if (isUndefined(draft)) {
                    return draft;
                }
                return isEmpty(draft) ? '' : draft;
            },

What alternative solutions did you explore? (Optional)

  • NA

@melvin-bot melvin-bot bot added the Overdue label Dec 14, 2023
Copy link

melvin-bot bot commented Dec 15, 2023

@rushatgabhane, @bfitzexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

Copy link

melvin-bot bot commented Dec 18, 2023

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

@rushatgabhane
Copy link
Member

reviewing

@melvin-bot melvin-bot bot removed the Overdue label Dec 18, 2023
@rushatgabhane
Copy link
Member

C+ reviewed 🎀 👀 🎀

I like @DylanDylann's proposal #32835 (comment)

Copy link

melvin-bot bot commented Dec 18, 2023

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

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 18, 2023
Copy link

melvin-bot bot commented Dec 18, 2023

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

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@aimane-chnaif
Copy link
Contributor

#32839 is similar to this one

@bernhardoj
Copy link
Contributor

bernhardoj commented Dec 19, 2023

@rushatgabhane I think it's better to remove the selector. The onyx data is simply a plain string.

There is no special logic in the selector, it just returns whatever values the onyx data have, which is the same as not having a selector. The selector just adds unnecessary complexity.

The selector logic basically,

  1. If it's not ready yet, return undefined so it keeps loading and loading it from the storage
  2. When it's ready, return the string

Which is already handled by withOnyx itself.

cc: @johnmlee101

@melvin-bot melvin-bot bot added the Reviewing Has a PR in review label Dec 19, 2023
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Dec 19, 2023
@DylanDylann
Copy link
Contributor

@rushatgabhane PR #33269 is ready to review

@DylanDylann
Copy link
Contributor

I think the important point in this issue is that we need to find out the RCA (Why the current selector does not work correctly). Use or not use the selector is just a refactor.

@bernhardoj
Copy link
Contributor

The main root cause is basically the same, that is the Onyx data is not available initially after a refresh, and both solutions are to keep the component "loading" the required data with a different approach, handling it manually or letting withOnyx handle it. IMO, a more detailed RCA shouldn't be selected over a better (letting withOnyx handle it, subjectively at this point) and the first solution. (except if my RCA is wrong)

@bernhardoj
Copy link
Contributor

bernhardoj commented Jan 10, 2024

So, will I get any compensation because my solution is used on the PR?

I'm still the same with my opinion above.

cc: @johnmlee101

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Jan 11, 2024
Copy link

melvin-bot bot commented Jan 11, 2024

This issue has not been updated in over 15 days. @johnmlee101, @rushatgabhane, @bfitzexpensify, @DylanDylann 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!

@rushatgabhane
Copy link
Member

  1. The PR that introduced the bug has been identified. Link to the PR: Fix/30992: Workspace invitation message still preserved #31770

  2. The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: https://github.com/Expensify/App/pull/31770/files#r1454592244

  3. A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N.A.

  4. Determine if we should create a regression test for this bug. No

  5. If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again - N.A.

@rushatgabhane
Copy link
Member

PR on prod 1 week ago. @bfitzexpensify could you please attach a payment summary. Thank you 🙇

@mountiny mountiny changed the title [$500] Workspace - Invite message does not remain when refresh page [HOLD for payment 2024-01-24] [$500] Workspace - Invite message does not remain when refresh page Jan 24, 2024
@mountiny mountiny added Awaiting Payment Auto-added when associated PR is deployed to production and removed Reviewing Has a PR in review labels Jan 24, 2024
@DylanDylann
Copy link
Contributor

@bfitzexpensify Could you help to move forward this issue?

@melvin-bot melvin-bot bot added Daily KSv2 and removed Monthly KSv2 labels Jan 30, 2024
@JmillsExpensify
Copy link

I'll step in on this one, as Ben is OOO.

Payment summary:

@JmillsExpensify
Copy link

@DylanDylann Your contract has been paid out.

@JmillsExpensify
Copy link

$500 payment approved for @rushatgabhane based on summary above.

@JmillsExpensify JmillsExpensify self-assigned this Jan 30, 2024
@JmillsExpensify
Copy link

Closing this issue, as no regression test is required.

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

10 participants