Sometimes this hook gets called with no contact_id, e.g. from the ContactLayout extension. This prevents errors in that situation.
This makes the hook both forward and backward compatible with current and future versions of core and the ContactLayout extension.