Here "hearts" is a metonym for their thoughts. To be loyal to him is spoken of as being solidly attached to him. Alternate translation: "their thoughts were not focused on him" or "they were not loyal to him" (See: [[rc://en/ta/man/translate/figs-idiom]])