Fix valid category check during preview form.

Previous check for '}' or '{' was insufficient. Due to a core bug,
passing an invalid category can cause a fatal. However we want to
catch the invalid categories anyways to show user a warning.

Bug: 68394
Change-Id: I5df84e50fd983ec286241549c16fbea07c541839