We present high signal-to-noise measurements of the average thermal Sunyaev Zel'dovich (tSZ) effect from optically selected groups and clusters using combined maps from the Atacama Cosmology Telescope (ACT) Data Releases 4 and 5 (DR4, DR5) and Planck along with sources from the Sloan Digital Sky Survey (SDSS) Baryon Oscillation Spectroscopic Survey (BOSS) DR15. We estimate the optical depths of the halos within a 2.1 arcminute radius aperture using results from cosmological hydrodynamic simulations, and compare the estimates to theoretical predictions of the baryon content for a Navarro-Frenk-White profile. We do the same for optical depth estimates extracted from fits to pairwise baryon momentum measurements of the kinematic Sunyaev-Zel'dovich effect (kSZ) for the same data set obtained in a companion paper. The SZ optical depth estimates account for one third to all of the theoretically predicted baryon content in the halos across luminosity bins. The tSZ and kSZ measurements provide a step towards empirical Compton-y-optical depth relationships which will provide new tests of cluster formation and evolution models.