Wait. No it doesn’t. It gets the ID OK, but it still has the kind of problem mentioned in the other thread:
“but then if the most recent post is belonged to a child category then the ID would be the child’s ID.”
That’s the problem. I think it is because the sidebar is done after the loop, so $cat holds the ID of the last category of the last post on the page.
However, single_cat_title('', false)
will get the proper category name I want, which is why I asked whether there was a way to convert that name to an ID.