Prepare the pie shell by baking it according to package instructions or your favorite homemade recipe. Allow it to cool completely.
In a medium mixing bowl, whisk together the sugar, flour, and salt until well combined.
In a medium saucepan, heat the milk over medium heat. Add the unsweetened chocolate squares and stir until melted and smooth.
Gradually add the dry ingredient mixture to the melted chocolate and milk, whisking continuously to prevent lumps from forming.
In a separate bowl, beat the egg yolks. Slowly add a bit of the hot chocolate mixture to the egg yolks, whisking constantly to temper the eggs.
Pour the tempered egg yolk mixture back into the saucepan with the chocolate mixture. Cook over medium heat, stirring continuously until the mixture thickens and bubbles, about 5-7 minutes.
Remove the saucepan from heat and stir in the butter, vanilla extract, and cream cheese. Whisk until smooth and well combined.
Carefully pour the chocolate filling into the cooled pie shell. Spread it evenly and smooth the top with a spatula.
Cover the pie with plastic wrap and refrigerate for at least 4 hours, or until set.