I seem to have solved this quest. For battle 1, just kill the treasure. For battle 2, sometimes leviathan will icebind the lamp, after which it can be destroyed by pincer attack. Otherwise it will eventually transform into the genie. Aladdin sometimes uses an “abracadabra” ability which appears to reduce enemy defenses dramatically. The genie does a cataclysm attack on death, dealing significant damage to your guardians. If your gear is very low it may kill them? Final battle, old senile Aladdin vs the genie, just don’t attack the genie and eventually it will vanish. You should get the “happy” ending with a picture of the genie smiling (not crying). At this point, you have a CHANCE of recruiting the genie. He appears in a luck chest. With 100 luck team I’ve gotten him 3 out of 4 times now (other time it was a mighty). I tried once with a low luck team and got nothing despite a happy end.