For every batch element of output of GRU I’m taking a certain timestep slice that corresponds to the last timestep for that sequence. This discards hidden states corresponding to padding time steps - that’s what I mean by “undoing the padding”

Thank you for that explanation, I understand your problem now.
Yes, that is my suggestion in the original post notation.