The Hartree-Fock potential
We rewrite
$$
\varepsilon_{a}^{\mathrm{HF}}=\varepsilon_a+ \frac{1}{2j_a+1}\sum_{i\le F}\sum_{m_a} \langle ai \vert \hat{V} \vert ai\rangle_{AS},
$$
as
$$
\varepsilon_{a}^{\mathrm{HF}}=\varepsilon_a+ \frac{1}{2j_a+1}\sum_{n_i,j_i,t_{z_{i}}\le F}\sum_{m_im_a}
\langle (j_am_aj_im_i)M | \hat{V} | (j_am_aj_im_i)M\rangle_{AS},
$$
where we have suppressed the dependence on \( n_p \) and \( t_z \) in the matrix element.
Using the definition
$$
\langle (j_am_aj_bm_b)M \vert \hat{V} \vert (j_cm_cj_dm_d)M\rangle=\frac{1}{N_{ab}N_{cd}}\sum_{JM}\langle j_am_aj_bm_b|JM\rangle\langle j_cm_cj_dm_d|JM\rangle \langle (j_aj_b)J \vert \hat{V} \vert (j_cj_d)M\rangle_{AS},
$$
with the orthogonality properties of Glebsch-Gordan coefficients and that the \( j \)-coupled two-body matrix element is a scalar and independent of \( M \) we arrive at
$$
\varepsilon_{a}^{\mathrm{HF}}=\varepsilon_a+ \frac{1}{2j_a+1}\sum_{j_i\le F}\sum_J (2J+1)
\langle (j_aj_i)J \vert \hat{V} \vert (j_aj_i)M\rangle_{AS},
$$