Season the pieces of steak with salt and pepper, then toss with the flour and shake off but reserve the excess. Heat 3 tbsp of the oil in a flameproof casserole or large saucepan and brown the meat in 2 batches until well coloured on all sides. Transfer to a plate.
Add another tbsp of the oil, half the butter and the mushrooms to the pan and fry briefly. Set aside with the beef. Add the rest of the oil and butter, the onions and sugar to the pan and fry over a medium-high heat for 20 minutes, until the onions are nicely browned. Stir in the reserved flour, then gradually add the Guinness and stock and bring to the boil, stirring.
Return the beef and mushrooms to the pan with the thyme, bay leaves, Worcestershire sauce, ¾ tsp of salt and some pepper, then cover and simmer for 1½ hours, until the meat is just tender.
Lift the meat, mushrooms and onions out of the liquid with a slotted spoon and put into a deep 1.2 litre (2 pint) pie dish. Bring the liquid to the boil and boil rapidly until reduced to 600 ml (1 pint). Remove and discard the bay leaves and thyme twigs, adjust the seasoning if necessary and pour into the pie dish. Stir everything together well and leave to cool completely.
Preheat the oven to 200C/400F/Gas 6. To open the oysters, wrap one hand in a tea towel and hold an oyster in it with the flat shell uppermost. Push the point of an oyster knife into the hinge, located at the narrowest point, and wiggle the knife back and forth until the hinge breaks and you can slide the knife between the 2 shells. Twist the point of the knife upwards to lever up the top shell, cut through the ligament and lift off the top shell. Release the oyster from the bottom shell and remove it, picking out any little bits of shell. Add the oysters to the pie dish and push them well down into the sauce. Push a pie funnel into the centre of the mixture.
Roll out the pastry on a lightly floured surface until it is 2.5cm (1in) larger than the top of the pie dish. Cut off a thin strip from around the edge, brush it with a little beaten egg and press it on to the rim of the dish. Brush it with more egg, cut a small cross into the centre of the larger piece of pastry and lay it over the dish so that the funnel pokes through the cross. Press the edges together well to seal. Trim away the excess overhanging pastry and crimp the edges between your fingers to give it an attractive finish. Chill for 20 minutes to relax the pastry.
Brush the top of the pie with beaten egg and bake for 30 to 35 minutes, until the pastry is crisp and golden and the filling is bubbling hot.