Superconducting transition-edge sensors (TESs) used in X-ray and \(\gamma\) -ray microcalorimeters suffer degraded performance if cooled in a magnetic field B sufficient to trap flux in the sensors. We report measurements of \(\gamma\) -ray TESs before and after implementing measures to reduce stray B fields from sources inside and outside the cryostat. These measurements showed a correlation between anomalous features in TES current–voltage (IV) curves and degraded energy resolution. After reducing internal sources of stray B field and improving shielding against external sources, both IV curves and energy resolution improved. Finally, we placed magnetized screws with remnant fields \(\sim\) 10 \(\upmu \textrm{T}\) near similar \(\gamma\) -ray TESs in a different type of detector package and observed the same effects.