Bring a small pot of salted water to a boil, add the onions, cook for 1 minute and drain well. Transfer to a bowl.
Combine the vinegar, sugar, salt and pepper in a small saucepan and bring to a boil. Cook until the sugar is dissolved, about 2 minutes. Remove from the heat, let cool slightly then pour the mixture over the onions. Cover and refrigerate for at least 4 hours. Stir in thyme before serving.
For the sauce:
Put the orange juice in a medium nonreactive saucepan and bring to a boil. Using a paring knife, make a small slit in the center of the habanero and add to the orange juice along with the allspice berries. Cook until thickened and reduced to about 1 cup. Strain into a bowl and let cool slightly. Add the zest and vinegar and season with salt, pepper and honey, to taste, if needed.
For the basil oil:
Combine the oil and basil in a blender and blend for 2 minutes. Strain into a bowl and season with salt and pepper.
For the fish:
Whisk together the flour, salt, pepper and enough water to make a batter with the consistency of crepe batter. Let sit 5 minutes.
Heat 2-inches of oil in a medium high-sided saute pan over high heat until it begins to shimmer. Put the flour in a large shallow bowl and season with salt and pepper. Season the fish with salt and pepper and dredged lightly in the flour, tapping off excess. Dip the fish in the batter and let excess drip off. Fry until golden brown. Drain on paper towels. Transfer to a platter, drizzle with the vinegar sauce and basil oil and top with some of the pickled red onions. Garnish with basil leaves.