The Githyanki Supreme Commander, in its stat block (Mordenkainen's Tome of Foes, p. 206), is granted three types of legendary actions, one of them being the Teleport action:
Teleport. The githyanki magically teleports, along with any equipment it is wearing and carrying, to an unoccupied space it can see within 30 feet of it. [...]
Simple. However, the description of the action continues:
[...] It also becomes insubstantial until the start of its next turn. While insubstantial, it can move through other creatures and objects as if they were difficult terrain. If it ends its turn inside an object, it takes 16 (3d10) force damage and is moved to the nearest unoccupied space.
Since legendary actions can only be taken "at the end of another creature's turn" (specified in the generic description of the Legendary actions), how can the Githyanki Supreme Commander move (or, as a matter of fact, end its turn inside an object) while insubstantial if the insubstantiality ends at the start of its turn?
Remember that it cannot teleport to a space it can't see, or to an occupied space.