In a medium bowl, beat the egg yolks.
In a medium saucepan, combine the sugar, flour, and salt. Use a fork or a whisk to mix them well.
Pour the milk into the pan and stir well with a whisk or a spatula until everything is very well combined and the dry ingredients seem to have dissolved.
Place the saucepan over medium heat and cook, still stirring with the whisk or spatula, until the mixture heats up and almost reaches a boil and steams and thickens into a smooth, velvety sauce, 6 to 8 minutes. Remove the pan from the heat.
Scoop out about 1/2 cup of the hot milk mixture with a measuring cup. Begin stirring the beaten egg yolks with a whisk or a large spoon and slowly, slowly start to add the 1/2 cup of the steaming hot milk mixture, stirring constantly as you pour. (This warms up the eggs and discourages them from curdling.)
Slowly pour the egg yolk and milk mixture back into the mixture in the pan, stirring until completely incorporated.
Place the pan back over medium heat and continue to cook, stirring and scraping the bottom of the pan often, for 2 to 3 minutes. Continue to cook, still stirring and scraping but a little more occasionally, until the mixture thickens considerably and begins retaining its shape when a blob is dropped from the spoon.
Let it come to a gentle but noisy boil, with large, blobby bubbles surfacing, popping, plopping, and steaming like lava in a cartoon volcano. Let it boil gently for 1 minute. Remove the pan from the heat.
Add 1 cup of the coconut, the butter, and the vanilla to the custard in the pan and stir to combine. When the butter is melted and incorporated into the custard, place a sheet of plastic wrap directly onto the surface of the custard and set it aside to cool to room temperature.
When the custard has cooled to room temperature, remove the plastic wrap and scoop the custard filling into the pie crust.