Measurements of the elliptic (\(v_2\)) and triangular (\(v_3\)) azimuthal anisotropy coefficients are presented for D\(^0\) mesons produced in b hadron decays (nonprompt D\(^0\) mesons) in lead-lead collisions at \(\sqrt{s_\mathrm{NN}}\) = 5.02 TeV. The results are compared with previously published charm meson anisotropies measured using prompt D\(^0\) mesons. The data were collected with the CMS detector in 2018 with an integrated luminosity of 0.58 nb\(^{-1}\). Azimuthal anisotropy is sensitive to the interactions of quarks with the hot and dense medium created in heavy ion collisions. Comparing results for prompt and nonprompt D\(^0\) mesons can assist in understanding the mass dependence of these interactions. The nonprompt results show lower magnitudes of \(v_2\) and \(v_3\) and weaker dependences on the meson transverse momentum and collision centrality than those found for prompt D\(^0\) mesons. By comparing to theoretical predictions, the results imply that there is a mass hierarchy of quark interactions with the medium.