Refactor group edit JavaScript to hide/show criteria field on document load