In the following MWE
\documentclass{article}
\usepackage{amsmath, environ}
\NewEnviron{hidden}{}
\def\hide#1{}
\begin{document}
\begin{align}
X &= Y \
% \begin{hidden} % DOES NOT WORK
&=Y_{1}%
\ &\leq Y_{2}\%
% \end{hidden}
\hide{&=Y_{3}\&=Y_{4}}
&\le Z
\end{align}
\begin{hidden}
Some more tests
\end{hidden}
\end{document}
I define a command and an environment to hide a certain part of the document (this is a simplification, my use case is a bit more complicated). The command works in all situation including an align environment. However, my new environment does not work inside align or similar commands. This is probably because \begin{hidden} \end{hidden} opens and closes a group within aligned which creates problems. Is there a way to create a dummy environment that does not create groups, much like a command seemingly does not.

&...&or&...\\is a group so whatever you set in\begin{hidden}will be lost at the first&(you will see same intabularorarrayand similar environments, not justalign– David Carlisle Nov 18 '20 at 11:16\hide)? If not, I don't understand why an environment would be different from a command, except for the introduction of the new group. – Tohiko Nov 18 '20 at 11:22{}in the command syntax automatically "hide" the&so as you skip over hat section the alignment cell does not end. For nested environemnts you have to work a bit harder (using the same special groups that are used so you can nest array or aligned inside align without the&ending the outer alignment – David Carlisle Nov 18 '20 at 11:32