So essentially, Kylo is the grandson of Anakin aka Vader who's father is Palpatine. So Palpatine is the great-grandfather of Kylo Ren aka Ben Solo-Skywalker.
I don't see how Rey factors into this at all.
Unless of course it turns out Palps had more children and Rey is a descendant of his.