I think the answer to the question linked by the OP can be misunderstood. That answer says, "The light emitted by stars passes through various gases, these gases absorb very specific wavelengths of light." This is not referring to clouds of gas between the star and us. Rather, it is talking about to gases in the star between the layer where the light was emitted and the outer limits of the star.
In an old-school spectrogram, they would take the light from a star, send it through a prism or diffraction grating, and use it to expose black and white film. They would just look at the negative, and you would get a dark stripe where the starlight exposed the negative. (They use optics to make it wider than just a line, which the stretched-out image of a star would be.) To be precise, you get a dark stripe except for every frequency where some element in the star's atmosphere absorbs light. That part of the dark stripe is not exposed and you get a line across the width of the stripe. Each element produces a recognizable pattern of lines, and if the star is moving relative to you, those lines will be shifted towards the long or short end of the spectrum.
If there were a nearby cloud of hydrogen absorbing light from a distant galaxy, the absorption lines caused by that cloud would not be shifted. Or, if we did observe them to be shifted, it would tell us about the motion of the cloud, not the distant galaxy.
I think photons from distant galaxies tend to be too low-energy to get absorbed by nearby hydrogen. But it can happen with stars in our galaxy. This site gives an example of a binary star in our galaxy on the other side of an interstellar cloud of hydrogen. Each star had hydrogen lines that were shifted back and forth as the star moved towards and then away from us (as they orbited each other). But there were other hydrogen lines that just stayed in the same place. Those were from the gas cloud.
So, the bottom line is that you are totally correct that using red shift to calculate how fast things are receding would not work if it depended on random intervening gas to generate the absorption spectrum. But it's actually gas associated to the star (or the whole galaxy if it's far enough away to be measured as a unit) that matters.