From the design document:
When a shard moves away its last chunk, it does not drop the collection or any indexes locally, creating an "orphaned" collection. Mongos will only target the shards that own chunks according to its routing table, so an index on an orphaned collection may become inconsistent with the indexes or collection options on chunk owning shards.
To handle this, when a non-primary shard receives its first chunk for a collection, it will drop the collection if it exists locally before copying the donor's indexes.
The primary shard for a collection should always have correct indexes so it must not drop the collection when it receives its first chunk.
The recipient shard should verify its DatabaseShardingState is up to date before checking if it is the primary shard.