Cannot upload files in submission copyediting stage when there are deleted notes

When trying to upload files in copyediting stage of submissions with deleted notes the file upload modal keeps showing “Loading” message and nothing appears.

In the error log:
PHP Fatal error: Uncaught Error: Call to a member function getAssocId() on null in /home/xxx/public_html/lib/pkp/controllers/grid/files/SubmissionFilesCategoryGridDataProvider.inc.php:131 Stack trace: #0 /home/xxx/public_html/lib/pkp/classes/controllers/grid/CategoryGridHandler.inc.php(402): SubmissionFilesCategoryGridDataProvider->loadCategoryData(Object(Request), 4, Array) #1 /home/xxx/public_html/lib/pkp/classes/controllers/grid/CategoryGridHandler.inc.php(124): CategoryGridHandler->loadCategoryData(Object(Request), 4, Array) #2 /home/xxx/public_html/lib/pkp/classes/controllers/grid/CategoryGridHandler.inc.php(473): CategoryGridHandler->getGridCategoryDataElements(Object(Request), 4) #3 /home/xxx/public_html/lib/pkp/classes/controllers/grid/CategoryGridHandler.inc.php(453): CategoryGridHandler->_renderCategoryInternally(Object(Request), Object(SelectableSubmissionFileListCategoryGridRow)) #4 /home/xxx/public_html/lib/pkp/classes/controllers/grid/CategoryGridHandler.inc.php(276): C...', referer: https://xxx/index.php/physics/workflow/index/726/4

I changed the following code line in controllers/grid/files/SubmissionFilesCategoryGridDataProvider.inc.php from:
$query = $queryDao->getById($note->getAssocId());
to:

if ($note){
$query = $queryDao->getById($note->getAssocId());
} else{
$query = null;
}

and solved the issue, but I’m not sure if it may cause other problems.

OJS version is 3.3.0.8