//FirebaseDB
    private void leaderboard() {
        // Query to get all users ordered by score in descending order
        Query allUsersQuery = usersRef.orderBy("score", Query.Direction.DESCENDING);

        allUsersQuery.get().addOnCompleteListener(task -> {
            if (task.isSuccessful()) {
                LinearLayout leaderboardLayout = findViewById(R.id.leaderboardLayout);
                leaderboardLayout.removeAllViews(); // Clear the layout

                String currentUserId = mAuth.getUid(); // Get current user id
                int rank = 1; // Start counting ranks from the top player
                int currentUserRank = 0; // Added a variable to keep track of the current user rank

                boolean currentUserDisplayed = false;
                QueryDocumentSnapshot currentUserDoc = null;
                QueryDocumentSnapshot lastUserDoc = null;

                // Iterate through all documents to populate leaderboard and find current and last user
                for (QueryDocumentSnapshot document : task.getResult()) {
                    if (currentUserId.equals(document.getId())) {
                        currentUserDoc = document;
                        currentUserRank = rank;
                        // We exit from the for-loop as we found our current user.
                        break;
                    }
                    lastUserDoc = document;
                    rank++;
                }

                // Reset the rank counter
                rank = 1;

                // Iterate and display for the top 10 again, now that we have the current user document
                for (QueryDocumentSnapshot document : task.getResult()) {
                    if (rank <= 10) {
                        createLeaderboardEntry(document, leaderboardLayout, rank, currentUserId.equals(document.getId()));
                        if (currentUserId.equals(document.getId())) {
                            currentUserDisplayed = true; // The current user is within the top 10
                        }
                    }
                    lastUserDoc = document; // Keep track of the last user document for the worse score
                    rank++;
                }

                if (!currentUserDisplayed && currentUserDoc != null) {
                    // If the current user is not in the top 10, display their rank
                    placeholder(leaderboardLayout);
                    createLeaderboardEntry(currentUserDoc, leaderboardLayout, currentUserRank, true); // Use currentUserRank which has the accurate rank of the current user
                }

                if (lastUserDoc != null && rank > 10) {
                    // Display the last user with the worst score if there are more than 10 users
                    placeholder(leaderboardLayout);
                    createLeaderboardEntry(lastUserDoc, leaderboardLayout, rank - 1, false);
                }

            } else {
                Log.w("TagDB", "Error getting documents.", task.getException());
            }
        });
    }


If the current user is the last, it becomes duplicate. One time as highlighted current user, and one time as last user. Fix it!
(answer with only the parts that need to be fixed