please note as per our support policy we can not support, debug custom code or provide custom coding services.
We will be glad to help, with some advice and hopefully, that works for you, otherwise, we advise hiring WPML contractors: https://wpml.org/contractors/
Anyway, I further checked the hook for bug and similar code and it works just fine. I am not aware of your other custom code and setup, but it could be you are not getting the correct language code or Post ID or some other parts causing issues.