My favorite reference for these sorts of things that straddle physics and geometry is Frankel's "The geometry of physics". In the chapter on harmonic forms, you will find what he refers to simply as "Hodge's Theorem". It's a little more general than you need, because it applies to general $p$-forms, and you only need functions (0-forms). So I'll specialize it to functions.
Hodge's Theorem (for functions): Let $M^n$ be a closed Riemannian manifold. Then Poisson's equation \begin{equation} \Delta \alpha = \rho \end{equation} (where $\alpha$ and $\rho$ are real-valued functions, and $\Delta$ is the Laplacian) has a solution $\alpha$ if and only if $\rho$ has mean value $0$ on $M^n$: \begin{equation} \int_M \rho\ \mathrm{vol}^n = 0. \tag{A} \end{equation}
So, to apply this theorem to your question, we have† \begin{align} M &= \partial \mathscr{B}, \\ \alpha &= y, \\ \rho &= \mathrm{const} - \left( p_{b ; d} \hat{h}^{bd} - R_{ac} Y^{a}_{1} Y^{c}_{2} + R_{adcb} Y^{d}_{1} Y^{c}_{2} Y^{a}_{2} Y^{b}_{1} \right). \tag{B} \\ \end{align} To put that another way, there is a solution for $y$ such that \begin{equation} y + p_{b ; d} \hat{h}^{bd} - R_{ac} Y^{a}_{1} Y^{c}_{2} + R_{adcb} Y^{d}_{1} Y^{c}_{2} Y^{a}_{2} Y^{b}_{1} = \mathrm{const} \end{equation} if and only if the integral of $\rho$ over $\partial \mathscr{B}$ is zero.
As Hawking & Ellis point out, $p_{b ; d} \hat{h}^{bd}$ is a pure divergence. So you can use Stokes' theorem to transform its integral over $\partial \mathscr{B}$ into an integral over the boundary of $\partial \mathscr{B}$. But the boundary of a boundary is always empty (at least for manifolds), so that integral has value $0$. Therefore, this term disappears when you integrate $\rho$. Now, combining this fact with (A) and (B), the theorem states that $y$ has a solution if and only if \begin{equation} \mathrm{const}\ \int_{\partial \mathscr{B}} \mathrm{vol}^n = \int_{\partial \mathscr{B}} \left( - R_{ac} Y^{a}_{1} Y^{c}_{2} + R_{adcb} Y^{d}_{1} Y^{c}_{2} Y^{a}_{2} Y^{b}_{1} \right)\ \mathrm{vol}^n. \end{equation} The volume (actually, the area of the surface) is assumed to be nonzero, and any volume (area) is non-negative, so the left-hand side is just the constant in question times some positive number.
Thus, as Hawking & Ellis claim, there exists a $y$ such that the first four terms in the original question's (1) add up to a constant, the sign of which is determined by the integral on the right-hand side above.
† Note that I have left out the $p'^a p'_a$ term in (1) from the original question; that term involves derivatives of $y$ other than the Laplacian, so Hodge's theorem doesn't apply to them. But also note that Hawking & Ellis don't actually claim that it should be included in what is equal to a constant.