Skip to content

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

Closed

Description

@kbecciv

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: 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

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 11, 2023
  2. changed the title [-]Workspace - Invite message does not remain when refresh page[/-] [+][$500] Workspace - Invite message does not remain when refresh page[/+] on Dec 11, 2023
  3. melvin-bot commented on Dec 11, 2023

    @melvin-bot

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

  4. melvin-bot commented on Dec 11, 2023

    @melvin-bot
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 11, 2023
  6. melvin-bot commented on Dec 11, 2023

    @melvin-bot

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

    @melvin-bot

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

  8. bernhardoj commented on Dec 11, 2023

    @bernhardoj
    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.

  9. AmjedNazzal commented on Dec 11, 2023

    @AmjedNazzal
    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
  10. DylanDylann commented on Dec 12, 2023

    @DylanDylann
    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?

    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
  11. 22 remaining items

  12. rushatgabhane commented on Jan 17, 2024

    @rushatgabhane
    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.

  13. rushatgabhane commented on Jan 17, 2024

    @rushatgabhane
    Member

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

  14. 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[/+] on Jan 24, 2024
  15. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed
    ReviewingHas a PR in review
    on Jan 24, 2024
  16. DylanDylann commented on Jan 26, 2024

    @DylanDylann
    Contributor

    @bfitzexpensify Could you help to move forward this issue?

  17. JmillsExpensify commented on Jan 30, 2024

    @JmillsExpensify
    Contributor

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

    Payment summary:

  18. JmillsExpensify commented on Jan 30, 2024

    @JmillsExpensify
    Contributor

    @DylanDylann Your contract has been paid out.

  19. JmillsExpensify commented on Jan 30, 2024

    @JmillsExpensify
    Contributor

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

  20. JmillsExpensify commented on Jan 30, 2024

    @JmillsExpensify
    Contributor

    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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions