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

"A room with this name already exists" message appears on Create New Room page #14010

Closed
6 tasks
kavimuru opened this issue Jan 5, 2023 · 30 comments
Closed
6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review

Comments

@kavimuru
Copy link

kavimuru commented Jan 5, 2023

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


Action Performed:

  1. Login with account that has policyRooms beta enabled
  2. Click FAB -> New Room
  3. Don't input anything and just click "Create Room" button
  4. "A room with this name already exists" message shows below Room Name input field
  5. Type any letter on Room Name field and erase all
  6. This time, "Please enter a room name" message shows below Room Name input field

Expected Result:

Error message should be consistent as "Please enter a room name"

Actual Result:

"A room with this name already exists" error shows first time

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:**v1.2.48-2
Reproducible in staging?: y
Reproducible in production?: y
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:

209856169-65c49370-e10c-4b86-9500-af45593cd55d.mov
Recording.1214.mp4

Expensify/Expensify Issue URL:
Issue reported by: @0xmiroslav
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1672852094448169

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01226a954977211217
  • Upwork Job ID: 1610968589634461696
  • Last Price Increase: 2023-01-05
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 5, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jan 5, 2023

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

@melvin-bot melvin-bot bot locked and limited conversation to collaborators Jan 5, 2023
@yuwenmemon yuwenmemon self-assigned this Jan 5, 2023
@yuwenmemon yuwenmemon added the Internal Requires API changes or must be handled by Expensify staff label Jan 5, 2023
@melvin-bot melvin-bot bot unlocked this conversation Jan 5, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jan 5, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01226a954977211217

@melvin-bot
Copy link

melvin-bot bot commented Jan 5, 2023

Triggered auto assignment to Contributor Plus for review of internal employee PR - @thesahindia (Internal)

@yuwenmemon
Copy link
Contributor

I can take a look at this one.

@jatinsonijs
Copy link
Contributor

@yuwenmemon I have found root case of this issue during testing. If you want I can post here. I'm asking bcz this issue is Internal and not allowed for external contributors.

@0xmiros
Copy link
Contributor

0xmiros commented Jan 5, 2023

function isExistingRoomName(roomName, reports, policyID) {
return _.some(
reports,
report => report && report.policyID === policyID
&& report.reportName === roomName,
);

undefined === undefined is the root cause.
I think we should add some more filters like this:

     return _.some( 
         reports, 
-        report => report && report.policyID === policyID 
-        && report.reportName === roomName,
+        report => report && !_.isEmpty(report.policyID) && report.policyID === policyID 
+        && !_.isEmpty(report.reportName) && report.reportName === roomName, 
     ); 

@jatinsonijs
Copy link
Contributor

What I have found is

we have added ReportFooter with loading state view.
In this PR #13523

/src/pages/home/ReportScreen.js

 <>
      <ReportActionsSkeletonView containerHeight={this.state.skeletonViewContainerHeight} />
      <ReportFooter shouldDisableCompose isOffline={this.props.network.isOffline} />
</>

We are not passing report in this case. Due to report not exist ReportFooter will use default prop
/src/pages/home/report/ReportFooter.js
LN: 52
report: {reportID: '0'},

and it will pass down to ReportActionCompose

<ReportActionCompose
    onSubmit={this.props.onSubmitComment}
    reportID={this.props.report.reportID.toString()}
    reportActions={this.props.reportActions}
    report={this.props.report}
    isComposerFullSize={this.props.isComposerFullSize}
    disabled={this.props.shouldDisableCompose}
/>

On component mount inside ReportActionCompose updateComponent function will trigger and it will call
// The draft has been deleted. if (newComment.length === 0) { Report.setReportWithDraft(this.props.reportID, false); }

Now in this case new incorrect report record will created with report_0: { hasDraft: false }

It will impact condition of check room name already exist or not

function isExistingRoomName(roomName, reports, policyID) {
  return _.some(
      reports,
      report => report && report.policyID === policyID
      && report.reportName === roomName,
  );
}

app has incorrect report record report_0: { hasDraft: false }

so it will check report exist true,
report.policyID === PolicyID will be true bcz both are undefined bcz we don't have default value of room name.
report.reportName === roomName will be true bcz both are undefined.

@fedirjh
Copy link
Contributor

fedirjh commented Jan 5, 2023

I think we should add validation as @0xmiroslav stated , we also have change this block to if else statement , the second validation is overwriting the first one

// We error if the user doesn't enter a room name or left blank
if (!values.roomName || values.roomName === CONST.POLICY.ROOM_PREFIX) {
errors.roomName = this.props.translate('newRoomPage.pleaseEnterRoomName');
}
// We error if the room name already exists.
if (ValidationUtils.isExistingRoomName(values.roomName, this.props.reports, values.policyID)) {
errors.roomName = this.props.translate('newRoomPage.roomAlreadyExistsError');
}

         // We error if the user doesn't enter a room name or left blank
+        // We error if the room name already exists.
         if (!values.roomName || values.roomName === CONST.POLICY.ROOM_PREFIX) {
             errors.roomName = this.props.translate('newRoomPage.pleaseEnterRoomName');
-        }
-
-        // We error if the room name already exists.
-        if (ValidationUtils.isExistingRoomName(values.roomName, this.props.reports, values.policyID)) {
+        } else if (ValidationUtils.isExistingRoomName(values.roomName, this.props.reports, values.policyID)) {
             errors.roomName = this.props.translate('newRoomPage.roomAlreadyExistsError');
         }

and for validation here I think this is enough

 function isExistingRoomName(roomName, reports, policyID) {
-    return _.some(
+    return roomName && _.some(
         reports,
         report => report && report.policyID === policyID
         && report.reportName === roomName,

@dhairyasenjaliya
Copy link
Contributor

Is this issue open for external? @yuwenmemon

@dhairyasenjaliya
Copy link
Contributor

  • not sure if it's available to work but I'm adding my analysis below

  • Here on the very first if we press save without adding any data we are validating the room name with the selected workspace which will fail because we never select any the workspace name in the first place (which will be always undefined)

  • In order to solve this issue we need one more conditional check for values.policyID and make sure if we select any workspace then only need to validate for existing workspace name into WorkspaceNewRoomPage.js

    if (ValidationUtils.isExistingRoomName(values.roomName, this.props.reports, values.policyID)) {

  • We will validate the Room name only if we select the workspace that will make sure to show the correct error validation

Changes

+        if (values.policyID && ValidationUtils.isExistingRoomName(values.roomName, this.props.reports, values.policyID)) {
            errors.roomName = this.props.translate('newRoomPage.roomAlreadyExistsError');
        }

Result

Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-01-05.at.17.08.44.mp4

@yuwenmemon

@yuwenmemon
Copy link
Contributor

This was fixed with: #13994

Also yes FYI @dhairyasenjaliya @fedirjh @0xmiroslav @jatinsonijs I appreciate the input but do please understand that this issue was tagged Internal and not marked either External or Help Wanted.

@0xmiros
Copy link
Contributor

0xmiros commented Jan 6, 2023

@yuwenmemon though this is internal, I think I am eligible for reporting compensation

@yuwenmemon
Copy link
Contributor

I believe that's correct @0xmiroslav but I will defer to @NicMendonca on that point.

@fedirjh
Copy link
Contributor

fedirjh commented Jan 6, 2023

@yuwenmemon I think this has not been fixed yet , now with this #13994 It will always skip the first validation , I still think that validation to same input field should go through an if - else :

  1. if (empty) shows empty error
  2. else if (invalid name) shows invalid error
  3. else if (used name) shows already used error
  4. else if (reserved name) shows reserved error

I think we can also add this rule to FORMS docs.

@yuwenmemon yuwenmemon reopened this Jan 6, 2023
@yuwenmemon
Copy link
Contributor

@fedirjh that's a good observation. I'll make that change, and we can work with @NicMendonca to ensure you get a bug reporting bonus.

@NicMendonca
Copy link
Contributor

NicMendonca commented Jan 6, 2023

@fedirjh can you please accept my proposal to the job here?

@NicMendonca NicMendonca changed the title "A room with this name already exists" message appears on Create New Room page [Reporting bonus] "A room with this name already exists" message appears on Create New Room page Jan 6, 2023
@fedirjh
Copy link
Contributor

fedirjh commented Jan 6, 2023

@NicMendonca Thank you, accepted!

@NicMendonca
Copy link
Contributor

@fedirjh paid the reporting bonus - thanks!

@NicMendonca NicMendonca changed the title [Reporting bonus] "A room with this name already exists" message appears on Create New Room page "A room with this name already exists" message appears on Create New Room page Jan 9, 2023
@0xmiros
Copy link
Contributor

0xmiros commented Jan 10, 2023

@NicMendonca I am also eligible for reporting bonus here

@yuwenmemon
Copy link
Contributor

@NicMendonca @0xmiroslav is correct 👍

@NicMendonca
Copy link
Contributor

@0xmiroslav can you please accept the job offer?

@0xmiros
Copy link
Contributor

0xmiros commented Jan 11, 2023

@0xmiroslav can you please accept the job offer?

accepted. thank you

@0xmiros
Copy link
Contributor

0xmiros commented Jan 11, 2023

@NicMendonca FYI: you hired me for $1000 but I am eligible for only $250

@NicMendonca
Copy link
Contributor

Ah, Thank you, I've created a new milestone 😄 Paid for $250

@NicMendonca
Copy link
Contributor

bonuses have both been paid ✅

@thesahindia
Copy link
Member

Hey @NicMendonca, C+ review compensation is due (sorry for the late comment).

@thesahindia
Copy link
Member

Bump @NicMendonca

@NicMendonca
Copy link
Contributor

@thesahindia can you accept the job offer, please?

@NicMendonca NicMendonca changed the title "A room with this name already exists" message appears on Create New Room page [Hold for C+ Payment] "A room with this name already exists" message appears on Create New Room page Jan 23, 2023
@NicMendonca
Copy link
Contributor

@thesahindia paid!

@NicMendonca NicMendonca changed the title [Hold for C+ Payment] "A room with this name already exists" message appears on Create New Room page "A room with this name already exists" message appears on Create New Room page Jan 24, 2023
@thesahindia
Copy link
Member

I think this can be closed now?

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 Engineering Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

8 participants