The refractive index in parts of the glass that the light has not yet reached has nothing to do with causing it to get to, but that is part of what makes it so that is on the path of least time from A to.