فَإِنْ صَلَّى أَرْبَعَ رَكَعَاتٍ، وَقَعَدَ فِي الْأَوَّلَيَيْنِ، ثُمَّ أَفْسَدَ الْأُخْرَيَيْنِ: قَضَى رَكْعَتَيْنِ.
Translation: If one performed a four-rakah nafl, sat after the first two and then invalidated the last two, one makes up two rakahs.
The sitting after the first pair gives that initial shaf‘ a completed legal status. Therefore, when only the later pair is invalidated, its makeup is two rakahs in the principal Hanafi ruling.
This specific judgment assumes that the sitting after the first two rakahs was correctly performed.