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

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

Closed
6 tasks done
lanitochka17 opened this issue Jan 15, 2024 · 8 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 15, 2024

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
@lanitochka17 lanitochka17 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 Jan 15, 2024
@melvin-bot melvin-bot bot 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 Jan 15, 2024
Copy link

melvin-bot bot commented Jan 15, 2024

Job added to Upwork: https://www.upwork.com/jobs/~0153cb4ce8578165a7

Copy link

melvin-bot bot commented Jan 15, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 15, 2024
Copy link

melvin-bot bot commented Jan 15, 2024

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

@BhuvaneshPatil
Copy link
Contributor

BhuvaneshPatil commented Jan 15, 2024

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)

@abzokhattab
Copy link
Contributor

abzokhattab commented Jan 15, 2024

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

@dummy-1111
Copy link
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)

@DylanDylann
Copy link
Contributor

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

@melvin-bot melvin-bot bot added the Overdue label Jan 17, 2024
@kadiealexander
Copy link
Contributor

kadiealexander commented Jan 19, 2024

Closing as a dupe of #32435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

7 participants