TikTok and parent company ByteDance have agreed to pay $400 million to settle a Justice Department lawsuit.