Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused attachment placeholder code #25557

Merged
merged 11 commits into from
Sep 29, 2023

Conversation

cubuspl42
Copy link
Contributor

@cubuspl42 cubuspl42 commented Aug 21, 2023

Details

I found this when working on #25415. Discussed here in a draft PR which I'd like to rebase on this one.

This code path seems to never trigger, as the report action's isLoading property seems to never be set.

Open questions:

  • Is the property supposed to be set by the backend?
  • Is this code supposed to execute or is it some leftover?

Removing this will simplify fixing #25415.

Fixed Issues

Helps with #25415

Tests

  • Go to a report with attachment messages
  • Upload an attachment
    • Verify that it uploads correctly
    • Verify that the behavior is the same as on production
  • Test interactions on the uploaded attachment
    • Verify that reactions, download, reply in thread and delete options work as expected
  • Upload a corrupted attachment
    • Verify that the upload fails
    • Verify that the comment is dimmed

Offline tests

QA Steps

Same as Tests

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
nuke-unused-attachment-preview-web.mp4
nuke-unused-attachment-preview-web-2.mp4
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android

@cubuspl42 cubuspl42 requested a review from a team as a code owner August 21, 2023 08:33
@melvin-bot melvin-bot bot requested review from flodnv and removed request for a team August 21, 2023 08:33
@melvin-bot
Copy link

melvin-bot bot commented Aug 21, 2023

@flodnv Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@cubuspl42 cubuspl42 force-pushed the nuke-unused-attachment-preview-1 branch from 8ccf412 to 82713e6 Compare August 21, 2023 08:38
Copy link
Contributor

@flodnv flodnv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the property supposed to be set by the backend?

I don't see any instance of isLoading in our backend code, so I guess not.

Is this code supposed to execute or is it some leftover?

No idea honestly, but if it's unreachable I think it's pretty safe to just remove it?

@@ -23,9 +23,6 @@ export default {
IOUTransactionID: PropTypes.string,
}),

/** Whether we have received a response back from the server */
isLoading: PropTypes.bool,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcaaron Any thoughts? You are to blame for this line 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I searched for isLoading and "isLoading" in the frontend code-base and I couldn't find any set of this property in the context of report actions.

flodnv
flodnv previously approved these changes Aug 21, 2023
Copy link
Contributor

@flodnv flodnv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - @marcaaron let us know your thoughts 🙇

@cubuspl42 cubuspl42 mentioned this pull request Aug 21, 2023
55 tasks
@marcaaron
Copy link
Contributor

yes, it is a relic! replaced with the pendingAction in this PR -> #10317

I would assume based on the age of that PR that anything referencing action.isLoading is dead code.

@marcaaron
Copy link
Contributor

Is there some linked issue though to go with this? What prompted this change?

@cubuspl42
Copy link
Contributor Author

@marcaaron

Is there some linked issue though to go with this? What prompted this change?

It started with this issue about some inconsistent 8px margin. I was the C+ reviewer. We introduced a regression trying to fix that inconsistency. I concluded that the reason why it's so difficult to apply that simple margin properly is the unnecessary complexity of the surrounding code. So now I'm cleaning it up, then I'll rebase #25524 on top of those cleanups. I hope it makes sense.

src/styles/StyleUtils.js Outdated Show resolved Hide resolved
@flodnv flodnv requested a review from marcaaron August 22, 2023 11:31
@marcaaron
Copy link
Contributor

It started with #24216 about some inconsistent 8px margin. I was the C+ reviewer. We introduced #25415 trying to fix that inconsistency. I concluded that the reason why it's so difficult to apply that simple margin properly is the unnecessary complexity of the surrounding code. So now I'm cleaning it up, then I'll rebase #25524 on top of those cleanups. I hope it makes sense.

I don't want to discourage your efforts (which we are appreciative of and seems like this is necessary cleanup). But I think it doesn't really make sense - or at least is unusual or outside of our normal process. Typically, if you want to do a refactor then you would propose somewhere the scope of the work. Then we create an issue for it. Then we accept that proposal. And then a PR like this get created and be linked to the issue. Then you will get compensated for it. Let me know if I am missing something.

@cubuspl42
Copy link
Contributor Author

But I think it doesn't really make sense - or at least is unusual or outside of our normal process.

I think it does make sense, but might indeed be outside of the process.

Then you will get compensated for it. Let me know if I am missing something.

I don't expect to be compensated for these cleanup PRs. And I skipped the formalities because the gain of removing the dead code and obvious duplication is hardly debatable.

As I understand, per the process C/C+ are obligated to fix the regression if it occurs during the regression period. Do you confirm that? So the only thing which is outside the process is that I classified the root cause of the regression lying in the unnecessary code complexity and organized the fix into a few smaller PRs, instead of 1 big one.

@marcaaron
Copy link
Contributor

I think it does make sense, but might indeed be outside of the process.

Yes, the change makes sense - sorry the explanation is what did not make sense to me because it looked (to me) like we did not quite follow process. To be sure, removing the code and all that is a good thing.

Since this is part of the solution to a regression then my recommendation would be to just link to the original issue in the description of this PR (so everyone can understand the context for the change). If you have made some plan to do the cleanup and got the approval to proceed then link to where that conversation happened.

To clarify my initial concern, it's that you might have been doing some random cleanup for which you would not be compensated for and nobody asked for. I see now that is a misunderstanding and that @Li357 gave you a green light already to open this PR.

@cubuspl42
Copy link
Contributor Author

it's that you might have been doing some random cleanup for which you would not be compensated for and nobody asked for

I still cannot see a problem here... I know that in general, it might be a challenge to accept PRs from the whole community because it's a cost to review them and might have negative net gain, but I think it's a bit different situation with the C+ group, who are filtered and have more experience in the project. We are also in the Expensify GitHub organization if that means anything.

If during a review I accidentally see some dead code (let's say in a file not strictly related to the solved issue), what am I supposed to do?

Typically, if you want to do a refactor then you would propose somewhere the scope of the work. Then we create an issue for it. Then we accept that proposal.

This? If that's the expectation, I will just pretend I didn't see that dead code, and so will others (or they already are doing that).

I'm not gonna argue about this, but I think that if anything, it's this specific part of the process that makes little sense.

But coming back to this PR, are we ready to push it forward?

@marcaaron
Copy link
Contributor

Overall, thanks for the thoughts and feedback! ❤️

it might be a challenge to accept PRs from the whole community because it's a cost to review them and might have negative net gain, but I think it's a bit different situation with the C+ group, who are filtered and have more experience in the project. We are also in the Expensify GitHub organization if that means anything.

This is not situation we have here though after reviewing the linked issue. So, perhaps we would like to restart this conversation in Slack with different context?

If during a review I accidentally see some dead code (let's say in a file not strictly related to the solved issue), what am I supposed to do?

It happens rarely in my experience. But sounds worth discussing.

We have various initiatives (particularly urgent ones at the moment) and a small internal team so it unfortunately does not always make sense to accept every improvement. But if we want to have some larger discussion about whether C+ team should feel empowered to submit improvement PRs without any connection to an issue then I would encourage it. 👍

Internally, most of us submit PRs connected to issues, but in very rare cases we do not. We are also salaried. So, my concerns with what you are suggesting boil down to:

  1. Everybody should be able to see why we are doing the work.
  2. People get compensated for the work they are doing.

But coming back to this PR, are we ready to push it forward?

Only remaining problem I see is this @cubuspl42:

2023-08-24_11-26-44

@cubuspl42
Copy link
Contributor Author

@marcaaron I linked #25415 as the "Fixed issue", although I don't fix it (yet), so it's fiction. I hope that satisfies the process, though. I don't have any idea what proposal I could link.

@cubuspl42
Copy link
Contributor Author

@situchan Can we move this forward?

@situchan
Copy link
Contributor

Server is down - https://expensify.slack.com/archives/C01GTK53T8Q/p1695314249132269
Will checklist once it's back

@flodnv
Copy link
Contributor

flodnv commented Sep 25, 2023

Can we merge this @situchan ?

@situchan
Copy link
Contributor

yes, we can. For safety, I wanna test based on latest codebase as 1415 commits are too behind
@cubuspl42 please pull main.

@cubuspl42
Copy link
Contributor Author

@situchan Done

@flodnv
Copy link
Contributor

flodnv commented Sep 28, 2023

Bump @situchan

@cubuspl42
Copy link
Contributor Author

@situchan Also, you can always merge main locally; if there are no conflicts, the conclusion from the testing reflects more-or-less the app behavior after the feature branch gets merge into main, unless there is a flaw in my logic

@situchan
Copy link
Contributor

Job 2 is failing. So still pull main

@situchan
Copy link
Contributor

situchan commented Sep 29, 2023

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Screen.Recording.2023-09-29.at.2.30.06.PM.mov
  • offline test
Screen.Recording.2023-09-29.at.2.38.19.PM.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android

Copy link
Contributor

@situchan situchan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the behavior is exactly same as main

@melvin-bot
Copy link

melvin-bot bot commented Sep 29, 2023

🎯 @situchan, thanks for reviewing and testing this PR! 🎉

An E/App issue has been created to issue payment here: #28450.

@flodnv flodnv merged commit 5b5bdc8 into Expensify:main Sep 29, 2023
14 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Oct 2, 2023

🚀 Deployed to staging by https://github.com/flodnv in version: 1.3.76-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Oct 3, 2023

🚀 Deployed to production by https://github.com/mountiny in version: 1.3.76-6 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Oct 3, 2023

🚀 Deployed to staging by https://github.com/flodnv in version: 1.3.77-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Oct 5, 2023

🚀 Deployed to production by https://github.com/mountiny in version: 1.3.77-7 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants