This is one of those problems where you need to try a few different solutions that can’t be solved by just logic.
For example if the body of the two rigs match as far as hierarchy goes but one has facial joints as children and you target the primary rig in UE4 then the added bones will be added as phantom or ghost bones to the first.
Rules for Sharing Skeleton Assets
By following the rules, which your question implies, the the same base rig can be used with similar or slightly different characters.
For example all of the free Paragon characters use the same base Epic rig but addition joints to account for individual but and unique player models so all though all animations will work on the Epic base rig, 3000+, what is not included would be added IF it’s a child of or shares common parent bones.
Another approach is if you do have custom animations for both parts as in
“I have a character who has head and body separated in two .fbx files.”
you could import the skeleton as individuals and composite the two separate elements as components of a Character BP, use the common root of the head and use the joint that is common to the head as a sub component of the body. Your body would then need an animation BP and your head would need an animation BP to drive secondary animation and expressions.
In the second configuration you could even make use of the MetaHuman heads