Fix bug with list of valid namespaces, and use Array.includes()
The validNamespaces
array was not actually being used when
checking for the current namespace ID. This fixes that bug, and
also uses the newer Array.includes() method which is nicer to
read than the older indexOf() way of checking array membership.
Bug: #330972