Decoupling electrical and thermal properties to enhance the figure of merit of thermoelectric materials underscores an in-depth understanding of the mechanisms that govern the transfer of charge carriers. Typically, a factor that contributes to the optimization of thermal conductivity is often found to be detrimental to the electrical transport properties. Here, we systematically investigated 26 dimeric MX2-type compounds (where M represents a metal and X represents a non-metal element) to explore the influence of the electronic configurations of metal cations on lattice thermal transport and thermoelectric performance using first-principles calculations. A principled scheme has been identified that the filled outer orbitals of the cation lead to a significantly lower lattice thermal conductivity compared to that of the partly occupied case for MX2, due to the much weakened bonds manifested by the shallow potential well, smaller interatomic force constants, and higher atomic displacement parameters. Based on these findings, we propose two ionic compounds, BaAs and BaSe2, to realize reasonable high electrical conductivities through the structural anisotropy caused by the inserted covalent X2 dimers, while still maintaining the large lattice anharmonicity. The combined superior electrical and thermal properties of BaSe2 lead to a high n-type thermoelectric ZT value of 2.3 at 500 K. This work clarifies the structural origin of the heat transport properties in dimeric MX2-type compounds and provides an insightful strategy for developing promising thermoelectric materials.