Over the years I have seen my plumbers doing re pipes for me use dielectric unions as well as brass nipples to join cooper to galvanized. I have never been called on the brass nipple. I am not sure it is per code or not. I had an inspection today that had close nipples and the ones I have had done used at least 3" nips. There was no sign of corrosion on the connection.
Looking around at all the forums ,the talk is that brass is more compatible with steel than copper . Apparently there is still some electrolysis going on,though at a slower rate.
Found a galvanic chart for compatibility that demonstrates what I said.
As a code question it may depend on locale.
I guess I can’t recall ever seeing a city inspector crawling under a house so maybe thats why it was never called out