When they had gone, an angel of the Lord appeared to Joseph in a dream. “Get up,” he said, “take the child and his mother and escape to Egypt. Stay there until I tell you, for Herod is going to search for the child to kill him.” (Matthew 2:13)
Fortunately (or maybe your opinion differs?) the country they fled to did not have mandatory detention at the time, so the child did not grow up in prison while his refugee status was being assessed.