I am trying to use a boolean environment within a \newcommand statement to selectively implement a verbatim environment. When I set the boolean to true it should put the "Answer" within the verbatim environment, effectively making it disappear. Instead, it spits out the error !File ended while scanning use of \next. Related, the boolean code from this answer.
\documentclass {article}
\usepackage {fontspec}
\setmainfont {TeX Gyre Schola}
\usepackage{etoolbox} % for booleans
\usepackage{verbatim} % for the comment environment
% setup a new boolean
\newbool{hidetrofficlight}
\setbool{hidetrofficlight}{true}
%%%%If the boolean is set to false
%%%%the verbatim environment is not implemented
%%%%and this code compiles fine, when set to "true"
%%%%it spits out the error "!File ended while scanning use of \next
% new environment
\newenvironment{answer}{}{}
% set conditional behavior of environment
\ifbool{hidetrofficlight}{\AtBeginEnvironment{answer}{\comment}%
\AtEndEnvironment{answer}{\endcomment}}{}
% macro for the answer using the boolean environment
\newcommand{\BA}[1]{\begin{answer}
\subsection*{Answer}#1.
\end{answer}}
% macro putting the question and answer together
\newcommand{\QA}[2]{%
\subsection{Question: \vskip.1in \noindent\normalsize #1?}
\BA{#2}
\addtocontents{toc}{\protect\vskip5pt}}
\begin{document}
\hsize6in
\hoffset-.5in
\noindent
\tableofcontents\eject
\centerline{\huge{Questions for Jonathan Dough}}
\QA{Did the donuts really need to be made}{Yes. Because the donuts needed to be eaten, we had to make them}
\end{document}
Double lualatex compiling with the boolean set to false gives the desired results:

But when compiled with a true boolean, instead of commenting out the "Answer" portion, it throws the error.

