I assume the environmental cost is dominated by other factors that apply in both cases: growing the plant, transporting the product, heating water to boiling temperatures.
teabags may well be a mature optimised technology, but they're releasing microplastics and that's worse than using 0.000% more energy, if you even are, which I doubt, when you factor in the additional weight required for transporting the bags, the transport of the wood for the paper, etc etc etc.
also, highly optimised does not mean highly optimised for the environment. where in Europe and parts of the America your energy supply may well be up to 40 or 50% renewables these days, or higher, you can be sure it isn't in the developing country your teabag was manufactured in. plus fumes, plus whatever land they stripped to plant the trees for the paper, if they're not cutting down old growth in the first place