I think your second approach is on the right track but you assume a
microtask is always callable + JSReceiver/JSFunction, which I don't
think is true - it can be a C++ callback or a promise reaction job,
for instance, and those don't have scripts or function objects
associated with them.
You should probably start by checking that
current_microtask->map().is_callable() is true and then add more type
checks on top. If you're only interested in JSFunctions, you can
probably get away with checking just
InstanceTypeChecker::IsJSFunction(current_microtask->map()->instance_type()).