Firebase firestore not finding document

I am making a social media app in Swift and am adding a feature for users to block people. This is the code I am using to tell the database that a user is blocked:

public func BlockUser(username: String) {
    let currentUser = UserDefaults.standard.value(forKey: "username") as! String
    let ref = database.collection("users")
        .document(currentUser)
        .collection("blocked")
        .document(username)
    ref.setData(["username": "username"])
}

And when a profile is opened, I use this code to check if they are blocked:

public var userIsBlocked: Bool = false

public func IsBlockedByUser(username: String) {
    let currentUser = UserDefaults.standard.value(forKey: "username") as! String
    let ref = database.collection("users")
        .document(currentUser)
        .collection("blocked")
        .document(username)
    ref.getDocument { (document, error) in
        if let document = document, document.exists {
            let dataDescription = document.data().map(String.init(describing:)) ?? "nil"
            print("Document data: \(dataDescription)")
            self.userIsBlocked = true
        } else {
            print("Document does not exist")
            self.userIsBlocked = false
        }
    }
}

I made sure that all the variables are correct and I can clearly see in the database that the document is there so why do I get the message "Document does not exist" when opening a blocked profile?

Here is what firebase looks like:

enter image description here

HHHH is the blocked user, CJMJM is the user who blocked HHHH.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum