The `length` property of an array [[ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length | can never be a negative number, and only a positive integer greater than or equal to 0 ]]. So `nouns.length` is guaranteed to be greater than 1 if the `maxNumberOfNouns === 1` conditional is reached.
In addition, after @palys-swm's review, I checked all instances of `lib/text/text-utils` (specifically calls to `pluralize` and `pluralizeAndTrim`) in the codebase to make sure this change did not break anything:
- Test to make sure `InlineSidebar`s are displayed correctly:
{F81001} {F81002}
Also, to be doubly sure, this is the usage of `pluralizeAndTrim` in `InlineSidebarText`, which calls `pluralizeAndTrim` with `maxNumberOfNouns = 25`. The code that was changed in this diff was in the conditional, which is only executed if `maxNumberOfNouns === 1`, so this change will not affect `InlineSidebar`.
{F81019}
- Test to make sure `JoinThreadMessageSpec` works correctly:
This is the only call to `pluralize`/usage of `text-utils` in `JoinThreadMessageSpec`:
{F81009}
Because this call to `pluralize` does not define the `maxNumberOfNouns` parameter, the code that was changed will never be executed since `maxNumberOfNouns` is by default initialized to 3 (see line 5 in this diff), not 1. The code that was changed in this diff was in the conditional, which is only executed if `maxNumberOfNouns === 1`, so this change will not affect `JoinThreadMessageSpec`.
- Test to make sure `thread-utils` works correctly:
This is the only call to `pluralize` in `thread-utils`:
{F81011}
Once again, because this call to `pluralize` does not define the `maxNumberOfNouns` parameter, the code that was changed will never be executed since `maxNumberOfNouns` is by default initialized to 3, not 1. Therefore, this change will not affect `thread-utils` (or anything that uses it).
- Test to make sure `LeaveThreadMessageSpec` works correctly:
Same logic as described above for `JoinThreadMessageSpec`:
{F81015}=