My question specifically refers to the proof of Proposition 3 given in chapter 9, section 9.3 of 'Abstract Algebra' by Dummit & Foote. I give the proposition here for convenience:
Let P be a prime ideal of the integral domain $R$, and let $f(x)$ be a monic polynomial of degree greater than or equal to $1$ in $R[x]$. Suppose, bar the leading coefficient, that the coefficients of $f$ are elements of $P$, and that the constant term of $f$ is not in $P^2$. Then $f$ is irreducible in $R[x]$.
It's assumed, for contradiction, that $f(x)$ is reducible in $R[x]$ so there exists non-zero polynomials $g,h \in R[x]$ such that $f$ is the product of these polynomials. We then reduce this equation $\bmod P$, where $P$ is a prime ideal in $R$. By the assumptions on the coefficients of $f(x)$, one is left with $x^n$ equal to the product of $g$ and $h$ where these polynomials now have coefficients in $(R/P)[x]$. Since $P$ is a prime ideal, $R/P$ is a domain and so it follows that $g$ and $h$ must have $0$ constant term i.e. the constant terms of $g$ and $h$ must both be in $P$. But we also have, in $R[x]$, that the constant term of $f$ is equal to the product of the constant terms of g and h implying that the constant term of $f$ is in $P^2$, a contradiction.
I don't understand why we can assume that both the constant terms of $g$ and $h$ must both be in $P$ by the above argument. Couldn't it be the case that say, for example, the constant term of $g$ was in $P$ but the constant term of $h$ was not. In this case, the constant term of the product of $g$ and $h$ would still be in $P$, but we would not be able to conclude with the contradiction given above.
I'll use an $\overline{\alpha}$ to denote the image of $\alpha\in R$ in the quotient $R/P$.
Because $(R/P)$ is a domain, and you have $$\overline{a}x^n = \overline{g}\overline{h},$$ then passing the the field of quotients of $R/P$ (and polynomials over fields have unique factorization) we conclude that $\overline{g}$ and $\overline{h}$ must be constant multiples of a power of $x$ in $(R/P)[x]$. That means that if, for example, $$g(x) = a_mx^m+\cdots + a_1x+a_0,$$ then reducing modulo $P$ you just get $\overline{g}(x)=\overline{a_m}x^m$. So $a_0,\ldots,a_{m-1}$ must lie in $P$. The same argument holds for $h$. So both the constant terms of $g$ and $h$ must both lie in $P$.