Issue with Filtering Data in Listview for Project Doctype

Hello Everyone,

I’ve been encountering an issue with filtering data in a listview for the Project doctype in my Frappe project. Initially, I attempted to use the prepare_data event, but it didn’t work as expected. Then, I shifted to using the onload event. However, even with this adjustment, I’m still facing challenges.
Here’s the code I’ve been working with:

frappe.listview_settings['Project'] = {
    prepare_data: function(data) {
        frappe.call({
            method: "auriga_erp_14.utils.listview_preparedata",
            args: {'user': frappe.session.user},
            callback: (r) => {
                if (r.message) {
                    let projectNames = r.message;
                    let filteredData = data.message.values.filter(row => {
                        const projectName = row[0];
                        return projectNames.includes(projectName);
                    });
                    return filteredData; // This doesn't work as expected
                }
            }
        })
    }
}

// Revised version using onload event
onload: function(listview) {
       listview.prepare_data = function(data) {
            frappe.call({
                method:"auriga_erp_14.utils.listview_preparedata",
                args: {'user' : frappe.session.user},
                async : false,
                callback(r){
                    if(r.message){
                        let projectNames = r.message;
                        filteredData = data.message.values.filter(row => {
                            const projectName = row[0];
                            return projectNames.includes(projectName);
                        });
                        return filteredData;                        
                    }
                }
            })
    }
}

By implementing these changes, I expect to resolve the issue with filtering data in the listview. However, despite these adjustments, the list is still not being populated correctly.

I would greatly appreciate any insights or suggestions from the community on how to resolve this issue.

Thank you for your time and assistance.

Best regards,
Anisha Jain

Reference: