Skip to content

[$500] Start Chat - Workspace not auto selected when creating Room for public existing user #34519

Closed

Description

@lanitochka17

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

Issue found when executing PR #34160

Action Performed:

Prerequisites: Existing public account with existing workspace

  1. Open https://staging.new.expensify.com/
  2. Log in with prerequisite account
  3. Click on the green plus button (FAB)
  4. Click on Start chat
  5. Click on Room tab if necessary

Expected Result:

Existing workspace should be automatically selected for Workspace field

Actual Result:

Workspace field is empty

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

Bug6343187_1705337737673.2024-01-15_16-50-32.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0153cb4ce8578165a7
  • Upwork Job ID: 1746945138582761472
  • Last Price Increase: 2024-01-15

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jan 15, 2024
  2. changed the title [-]Start Chat - Workspace not auto selected when creating Room for public existing user[/-] [+][$500] Start Chat - Workspace not auto selected when creating Room for public existing user[/+] on Jan 15, 2024
  3. melvin-bot commented on Jan 15, 2024

    @melvin-bot
  4. melvin-bot commented on Jan 15, 2024

    @melvin-bot

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

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 15, 2024
  6. melvin-bot commented on Jan 15, 2024

    @melvin-bot

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

  7. BhuvaneshPatil commented on Jan 15, 2024

    @BhuvaneshPatil
    Contributor

    Proposal

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

    Start Chat - Workspace not auto selected when creating Room for public existing user

    What is the root cause of that problem?

    we are not initialising any value for policyID in WorkspaceNewRoomPage. We are setting it as null.

    const [policyID, setPolicyID] = useState(props.activePolicyID);

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

    1. Set the state initially like this
        const [policyID, setPolicyID] = useState(PolicyUtils.getActivePolicies(props.policies).at(0)?.id || null);

    Currently we are setting it as first policy, we can change to other index if required
    2. use that value in InputWrapper for policy

                                    <InputWrapper
                                        InputComponent={ValuePicker}
                                        inputID="policyID"
                                        label={translate('workspace.common.workspace')}
                                        items={workspaceOptions}
                                        onValueChange={setPolicyID}
                                        value={policyID}
                                    />

    What alternative solutions did you explore? (Optional)

  8. abzokhattab commented on Jan 15, 2024

    @abzokhattab
    Contributor

    Proposal

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

    Workspace not auto selected when creating Room for public existing user

    What is the root cause of that problem?

    The backend doesn't return the account.activePolicyID https://github.com/Expensify/App/blob/a4e3ae2546882b0971ed80e6ce0fd4c6b85cf956/src/pages/workspace/WorkspaceNewRoomPage.js#L369C2-L373C11

    thats why the displays empty workspace

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

    either this issue is fixed in the backend,

    or we add a fallback to select the first workspace if the account.activePolicyID is not returned:

    if we go with this approach then we need to change this https://github.com/Expensify/App/blob/a4e3ae2546882b0971ed80e6ce0fd4c6b85cf956/src/pages/workspace/WorkspaceNewRoomPage.js#L103C5-L103C5

    to

        const [policyID, setPolicyID] = useState(props.activePolicyID ||  props.policies[0].id);

    we can of course use lodash to safely access those the props.policies object

  9. dummy-1111 commented on Jan 15, 2024

    @dummy-1111
    Contributor

    Proposal

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

    Workspace isn't auto selected in creating room page even when there are active workspaces

    What is the root cause of that problem?

    We have two code segments to initialize the workspace value

    const [policyID, setPolicyID] = useState(props.activePolicyID);

    useEffect(() => {
    if (policyID) {
    return;
    }
    setPolicyID(props.activePolicyID);
    }, [props.activePolicyID, policyID]);

    The problem is the value of activePolicyID. There may be 2 cases

    • activePolicyID is empty
    • activePolicyID isn't included in active policies

    These cases were not handled. This is the root cause

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

    We need to handle the above 2 cases

    1. Move this code above this line
    2. Update the effect code as follows
        useEffect(() => {
            if (workspaceOptions.length === 0 || policyID && workspaceOptions.some(option => option.value === policyID)) {
                return;
            }
            if (props.activePolicyID && workspaceOptions.some(option => option.value === policyID)) {
                setPolicyID(props.activePolicyID);
            } else {
                setPolicyID(workspaceOptions[0].value);
            }
        }, [props.activePolicyID, policyID, workspaceOptions]);
    

    This works as expected

    Result
    34519.mp4

    What alternative solutions did you explore? (Optional)

  10. DylanDylann commented on Jan 16, 2024

    @DylanDylann
    Contributor

    This feature is done here, It seems we need to wait a update from BE
    cc @alitoshmatov @s-alves10

  11. kadiealexander commented on Jan 19, 2024

    @kadiealexander
    Contributor

    Closing as a dupe of #32435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions