Things here are simple, selected bone joint could have same priority as unselected bone, so bone would always win. Gave joints a little more priority than bones, usually user will be more precise just to select the joint anyway.
BLI_strncpy_wchar_as_utf8()