When the universe expands, it is important to understand that how its energy content evolves depends on the form of energy involved. If all that energy is locked up in the form of mass energy, then the density of that matter will decrease proportionally to the relative increase of any arbitrary volume of the universe (i.e. if expansion doubles the size of things, all volumes will be multiplied by 8, and correspondingly all densities will be divided by 8). In other words, if $a$ is the scale factor of the universe, and $\rho_m$ its matter density, we have :
$$
\rho_m \propto a^{-3}
$$
Hence, the total amount of mass energy (which is $\rho_m \times a^3$) is conserved. What happens if the energy content of the universe is dominated by radiation ? In that situation, on top of the decrease in density, radiation is also redshifted proportionally to the scale factor. Hence, if $\rho_R$ is the radiation energy density, we have :
$$
\rho_R \propto a^{-4}
$$
Here, the total energy ($\rho_R \times a^3$) is not conserved, which, remember, is not a problem in General Relativity. The period your textbook is referring to is likely the radiation era (roughly the first $50,000$ years of the universe's history). Indeed, during this time, the universe cooled in a way that decreased the total energy of the universe. It didn't go anywhere, it is indeed "lost" in a sense.
Conversely, we can have a situation where energy is gained. This is the case for any dark energy model, but let's keep it simple and consider the case of a cosmological constant $\Lambda$. This corresponds to a constant energy density. That is to say $\rho_\Lambda$ is independent of $a$. The total energy will then be $\rho_\Lambda \times a^3$, and will therefore increase with expansion.
Here I loosely used the word "total" given that it doesn't mean much in an infinite universe. A more rigorous expression for "total" would be any arbitrarily chosen sphere in comoving coordinates, so long as its radius is above the inhomogeneity scale.