I've tried solutions posted in here, here, and other relevant posts to no avail. I'm trying to use hyperref in document that uses natbib and bibentry, but it gives me tons of errors. The major difference between my issue and others posts is that I'm using bibentry in a section heading, in which I had to use \protect to make it work.
Please see my code below:
\begin{filecontents}{test.bib}
@article{mccarty2018theory,
author = {McCarty, Nolan and Schickler, Eric},
date-added = {2021-05-16 19:43:59 -0400},
date-modified = {2021-05-16 19:43:59 -0400},
journal = {Annual Review of Political Science},
pages = {175--193},
publisher = {Annual Reviews},
title = {On the theory of parties},
volume = {21},
year = {2018}}
}
\end{filecontents}
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{titlesec}
\usepackage{hanging}
\usepackage{color}
\usepackage{natbib}
\bibliographystyle{apa}
\usepackage{bibentry}
\makeatletter\let\saved@bibitem@bibitem\makeatother
\usepackage{hyperref}
\makeatletter\let@bibitem\saved@bibitem\makeatother
\author{Test}
\title{Test}
\titleformat{\section}{\normalsize\bfseries}
\titleformat{\subsection}{\normalsize\bfseries}
\titleformat*{\subsubsection}{\normalsize\bfseries}
\makeatletter
\renewcommand\BR@b@bibitem[2][]{\BR@bibitem[#1]{#2}\BR@c@bibitem{#2}}
\makeatother
\nobibliography*
\begin{document}
\maketitle
\tableofcontents
\section{\protect\bibentry{mccarty2018theory}} %THIS LINE CAUSES AN ERROR
\cite{mccarty2018theory} blah blah blah ...
\clearpage
\bibliography{test.bib}
\end{document}

\section[Alternative Section Title]{\protect\bibentry{mccarty2018theory}}? I believehyperrefwill just get into massive trouble trying to make a bookmark out of this section title. – Manuel Weinkauf Jun 30 '21 at 16:39\sectionbut the material that has to go into the bookmarks column. – Mico Jun 30 '21 at 17:11