“Lord Bowen, as quoted in "Pie Powder", Being Dust from the Law Courts, Collected and Recollected on the Western Circuit, by a Circuit Tramp (1911) by John Alderson Foote; this seems to be the earliest account of any similar expression. It is mentioned by the author that this expression has become misquoted as a "black cat" rather than "black hat.”
Source: Wikiquote